Skip to content

Commit 550ac8a

Browse files
committed
Fix order of -- and - in cat command
Somewhat unintuitively, the "-" is considered to be a file operand and not an option, even though it treated to signify standard input rather than a file named "-". On some systems including macOS, options to cat cannot follow paths. On those systems, writing "-" before "--" causes "--" to be treated as a filename, causing the script to break on macOS. This changes the order, which lets the cat command work on all systems, though (as before) if the subsequent argument were a literal "-" then that would not have the desired effect. In this case that is okay, since we actually know that the other argument, the value of the source_file variable, is not exactly "-". (We even know that it does not begin "-". But keeping the "--" before it makes clearer to human readers that this argument is a path and never an option.)
1 parent deeac5e commit 550ac8a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

etc/copy-packetline.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function copy_with_header () {
101101
fi
102102

103103
make_header "$source_file" "$endline" |
104-
cat - -- "$source_file" >"$target_file"
104+
cat -- - "$source_file" >"$target_file"
105105
}
106106

107107
function generate_one () {

0 commit comments

Comments
 (0)