Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site watmath.UUCP Path: utzoo!watmath!idallen From: idallen@watmath.UUCP Newsgroups: net.unix Subject: Fun (?) with SH. (Surprising behaviour...) Message-ID: <7356@watmath.UUCP> Date: Fri, 23-Mar-84 16:55:48 EST Article-I.D.: watmath.7356 Posted: Fri Mar 23 16:55:48 1984 Date-Received: Sun, 25-Mar-84 08:17:48 EST Organization: U of Waterloo, Ontario Lines: 19 What does this line in a Bourne Shell command file print, when called with the command arguments "1 2 3 4"? sh -c "/bin/echo And $@ were my arguments." Answer: And 1 Why? Because of the way "$@" expands, the command line becomes: sh -c "/bin/echo And 1" "2" "3" "4 were my arguments." The invoked shell silently ignores the "2" and all following arguments, and it executes "/bin/echo And 1". I suppose this variation on the expansion of "$@" makes sense (?!), but what reason is there to silently ignore the following arguments? (p.s. To fix the problem, change @ to *.) -- -IAN! (Ian! D. Allen) University of Waterloo