From 4f869bccc14fb2fa19df130e76c022765ecda924 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 22 Nov 2017 16:29:57 -0500 Subject: [PATCH] cc-wrapper: Don't treat "-" alone as a flag It means stdin, and is morally equivalent to passing a file. e.g. $ echo 'int main(void) { return 0; }' | gcc -x c - will compile and link a binary. --- pkgs/build-support/cc-wrapper/cc-wrapper.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index 82f5c6443d54..df1afef33745 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -59,7 +59,8 @@ while (( "$n" < "$nParams" )); do cppInclude=0 elif [ "$p" = -nostdinc++ ]; then cppInclude=0 - elif [ "${p:0:1}" != - ]; then + elif [[ "$p" != -?* ]]; then + # A dash alone signifies standard input; it is not a flag nonFlagArgs=1 fi n+=1