Path: utzoo!censor!geac!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!batcomputer!munnari.oz.au!mtiame!marvin!david From: david@marvin.jpl.oz (David Magnay) Newsgroups: comp.unix.shell Subject: Shell METACHAR's in parameters Message-ID: <829@marvin.jpl.oz> Date: 22 Jan 91 00:44:03 GMT Organization: Johns Perry Lifts, Melbourne, Australia Lines: 19 Can anyone supply a "rule" of how to consistently handle shell parameters inside a script, when the parameter MAY contain shell metacharacters or a regular expression. The danger is that the shell is will process the characters, rather than pass them literally. We also should be able to pass regular expressions down into a script from within a script, indefinitely. Again, without knowing whether the param has metachar's or not. This first showed up in a script to "tidy up" the "find" utility with a friendlier interface. I found that the script would intermittently fail silently. If I pass a parameter "file*" as a parameter, it passes literally if it matches NO files in the current directory, but is expanded if any matching files exist. ( try "echo kkxx*" ). This is fixed by the user quoting the command line when invoking the script. But I still found funnies occasionally, presuamble because of unwise usage of parameters inside the script. What I cant see is the RULE of guidance, so I dont repeat the problem.