lanzo@wgate.wgate.com (Mark Lanzo) (07/26/90)
I ran into a strange problem when I was writing a "sh" script. I do not know whether or not this is a bug. if it is, I will report it to the local vendor's support line, but I'd like to find out for sure before I send the support folks on a wild goose chase. So what's the verdict on what the correct response the following script should produce? Thanks in advance, Mark Lanzo ...!uunet!wgate!lanzo (lanzo@wgate.com) -------------------------%<---snip here (but you knew that, didn't you?)------ #!/bin/sh # # A script to demonstrate a possible shell bug. # # Assume that the current directory contains the files "f1", "f2", and "f3", # and "bug" (this script), and I run this script in it. # What should the output of the script be? # # I would expect this: # Arguments are a b c # bug f1 f2 f3 # Arguments now are a b c # # But instead I actually see: # Arguments are a b c # bug f1 f2 f3 # Arguments now are bug f1 f2 f3 # # When calling shell "functions", the positional parameters ($1, $2...) # are supposed to be set to the arguments of the function. Apparently # this blows away all the positional parameters of all the calling (higher # level) functions! # This does not happen on our system if I use "/bin/ksh" instead; # it gives the first response shown above. ECHO() { echo "$*" } show_bug() { echo Arguments are "$*" ECHO * echo Arguments now are "$*" } show_bug a b c