Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!snorkelwacker!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!warwick!cudcv From: cudcv@warwick.ac.uk (Rob McMahon) Newsgroups: comp.unix.questions Subject: Re: KSH script arguments Message-ID: <1990Aug31.111742.7841@warwick.ac.uk> Date: 31 Aug 90 11:17:42 GMT References: <1992@hsi86.hsi.UUCP> Sender: news@warwick.ac.uk (Network news) Distribution: comp.unix.questions Organization: Computing Services, Warwick University, UK Lines: 30 In article <1992@hsi86.hsi.UUCP> kenney@hsi.com (Brian Kenney) writes: >In article jonc@amdahl.uts.amdahl.com (Jonathan Chang) writes: > >>How can I extract the last argument to a ksh script? >>Example: >> myscript arg1 arg2 arg3 > >args=$* >arg3=${args##* } > >You're welcome. Of course this breaks horribly if the last argument contains a space. (Actually it doesn't work at all with bash, you need to escape the ` ' with a `\', is this a bug ?) This is one of my pet peeves. People create files with spaces in their names (often from packages), and I like to be able to tell them "Don't panic, just surround the names with ''", I don't want to have to say "If you're using x or y you can use '', but you can't use this with z because it's a shell script, although of course it does work with w because it's a csh script." People shouldn't have to know how things are implemented. (Yes, yes, I know, I should say "just don't create files with spaces in the name :-(, but that doesn't work for messages, the title of printer jobs, etc.) Rob -- UUCP: ...!mcsun!ukc!warwick!cudcv PHONE: +44 203 523037 JANET: cudcv@uk.ac.warwick INET: cudcv@warwick.ac.uk Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England