diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2009-11-13 15:13:01 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2009-11-13 15:13:01 -0800 |
commit | 34020d9344dbce334486ea9c3f5babdc6fbcbe10 (patch) | |
tree | f63ccd35ab0f8b3303bd65f3eb22f9655aabdb49 /txr.1 | |
parent | 95e59dd555a038fd6eb70bc38e4e921d811b1f49 (diff) | |
download | txr-34020d9344dbce334486ea9c3f5babdc6fbcbe10.tar.gz txr-34020d9344dbce334486ea9c3f5babdc6fbcbe10.tar.bz2 txr-34020d9344dbce334486ea9c3f5babdc6fbcbe10.zip |
Allow -c scripts to not have a trailing newline.
Test suite exercises -c now.
txr.c (txr_main): If the script specified with -c is not terminated
by a newline, just add a newline. On the shell command line, it's a
nuisance to have to add the extra line before closing the quote.
It's also awkward in scripting, because the shell (or at
least Bash 3.0) does not produce a final terminating newline in command
substitution syntax like -c "$(cat file)". The last newline in
the file is trimmed, and has to be explicitly added in the script
itself, which is wrong in the case when the file is empty.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -141,8 +141,10 @@ the dimension order is: NAME_m_m+1_..._n[1][2]...[m-1]. Specifies the query in the form of a command line argument. If this option is used, the query-file argument is omitted. The first non-option argument, if there is one, now specifies the first input source rather than a query. -Queries specified as arguments must properly end in a newline, as if they -were read from a text file, thus -c "@a" is not a properly formed query. +Unlike queries read from a file, (non-empty) queries specified as arguments +using -c do not have to properly end in a newline. Internally, txr +adds the missing newline before parsing the query. Thus -c "@a" +is a valid query which matches a line. Example: @@ -152,8 +154,7 @@ Example: # comes from shell "here document" redirection. txr -c "@a - @b - " - <<! + @b" - <<! 1 2 ! @@ -166,8 +167,7 @@ The @# comment syntax can be used for better formatting: txr -c "@# @a - @b - " + @b" .IP -f query-file Specifies the file from which the query is to be read, instead of the |