Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!rpi!uupsi!rodan!rodan.acs.syr.edu!jdpeek From: jdpeek@rodan.acs.syr.edu (Jerry Peek) Newsgroups: comp.unix.questions Subject: sh(1) question from a "quoting paranoiac" :-) Message-ID: <2387@rodan.acs.syr.edu> Date: 8 Mar 90 11:42:36 GMT Sender: netnews@rodan.acs.syr.edu Reply-To: jdpeek@rodan.acs.syr.edu (Jerry Peek) Organization: Syracuse University, Syracuse, NY Lines: 25 I'm using these lines in a BSD-type Bourne shell script. They give me the last command line argument in $last and the others in $first: last="`expr \"$*\" : '.* \(.*\)'`" # LAST ARGUMENT first="`expr \"$*\" : '\(.*\) .*'`" # ALL BUT LAST ARG Seems like, years ago, I needed to put doublequotes around the backquotes to protect any spaces from the shell. So, I write quoting nightmares like that one. But maybe I've got over-quoting paranoia. :-) Would this be safe? last=`expr "$*" : '.* \(.*\)'` # LAST ARGUMENT first=`expr "$*" : '\(.*\) .*'` # ALL BUT LAST ARG Our BSD-type sh(1) man page seems to say that it's okay (?): After parameter and command substitution, any results of substitution are scanned for internal field separator char- acters (those found in $IFS) and split into distinct argu- ments where such characters are found... I'd like this script to be portable. Is there any Bourne shell (including mine!) that will choke on the less-quoted version? Thanks. --Jerry Peek; Syracuse University Academic Computing Services; Syracuse, NY jdpeek@rodan.acs.syr.edu, JDPEEK@SUNRISE.BITNET +1 315 443-3995