From 1cfbcf183ecc4cf4cf78fcee7fd90dfe01a04d10 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Mon, 8 Apr 2024 20:24:38 -0400 Subject: [PATCH] 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.) --- etc/copy-packetline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/copy-packetline.sh b/etc/copy-packetline.sh index 688f16aa4f0..2aea00a225e 100755 --- a/etc/copy-packetline.sh +++ b/etc/copy-packetline.sh @@ -101,7 +101,7 @@ function copy_with_header () { fi make_header "$source_file" "$endline" | - cat - -- "$source_file" >"$target_file" + cat -- - "$source_file" >"$target_file" } function generate_one () {