diff --git a/docs/src/manpage.md b/docs/src/manpage.md index a7929a937..12661b15e 100644 --- a/docs/src/manpage.md +++ b/docs/src/manpage.md @@ -3731,5 +3731,5 @@ This is simply a copy of what you should see on running `man mlr` at a command p MIME Type for Comma-Separated Values (CSV) Files, the Miller docsite https://miller.readthedocs.io - 2024-06-08 4mMILLER24m(1) + 2024-06-09 4mMILLER24m(1) diff --git a/docs/src/manpage.txt b/docs/src/manpage.txt index 4975b7646..93be575b4 100644 --- a/docs/src/manpage.txt +++ b/docs/src/manpage.txt @@ -3710,4 +3710,4 @@ MIME Type for Comma-Separated Values (CSV) Files, the Miller docsite https://miller.readthedocs.io - 2024-06-08 4mMILLER24m(1) + 2024-06-09 4mMILLER24m(1) diff --git a/man/manpage.txt b/man/manpage.txt index 4975b7646..93be575b4 100644 --- a/man/manpage.txt +++ b/man/manpage.txt @@ -3710,4 +3710,4 @@ MIME Type for Comma-Separated Values (CSV) Files, the Miller docsite https://miller.readthedocs.io - 2024-06-08 4mMILLER24m(1) + 2024-06-09 4mMILLER24m(1) diff --git a/man/mlr.1 b/man/mlr.1 index a123eaf20..822d44f06 100644 --- a/man/mlr.1 +++ b/man/mlr.1 @@ -2,12 +2,12 @@ .\" Title: mlr .\" Author: [see the "AUTHOR" section] .\" Generator: ./mkman.rb -.\" Date: 2024-06-08 +.\" Date: 2024-06-09 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "MILLER" "1" "2024-06-08" "\ \&" "\ \&" +.TH "MILLER" "1" "2024-06-09" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Portability definitions .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pkg/transformers/put_or_filter.go b/pkg/transformers/put_or_filter.go index 5ba42435b..82f57e940 100644 --- a/pkg/transformers/put_or_filter.go +++ b/pkg/transformers/put_or_filter.go @@ -247,14 +247,28 @@ func transformerPutOrFilterParseCLI( } else if opt == "-f" { // Get a DSL string from the user-specified filename filename := cli.VerbGetStringArgOrDie(verb, opt, args, &argi, argc) - theseDSLStrings, err := lib.LoadStringsFromFileOrDir(filename, ".mlr") - if err != nil { - fmt.Fprintf(os.Stderr, "%s %s: cannot load DSL expression from file \"%s\": ", - "mlr", verb, filename) - fmt.Println(err) - os.Exit(1) + + // Miller has a two-pass command-line parser. If the user does + // `mlr put -f foo.mlr` + // then that file can be parsed both times. But if the user does + // `mlr put -f <( echo 'some expression goes here' )` + // that will read stdin. (The filename will come in as "dev/fd/63" or what have you.) + // But this file _cannot_ be read twice. So, if doConstruct==false -- we're + // on the first pass of the command-line parser -- don't bother to parse + // the DSL-contents file. + // + // See also https://github.com/johnkerl/miller/issues/1515 + + if doConstruct { + theseDSLStrings, err := lib.LoadStringsFromFileOrDir(filename, ".mlr") + if err != nil { + fmt.Fprintf(os.Stderr, "%s %s: cannot load DSL expression from file \"%s\": ", + "mlr", verb, filename) + fmt.Println(err) + os.Exit(1) + } + dslStrings = append(dslStrings, theseDSLStrings...) } - dslStrings = append(dslStrings, theseDSLStrings...) haveDSLStringsHere = true } else if opt == "-e" {