[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: shell script question



On Mon, Oct 13, 2003 at 11:27:23AM -0400, David Z Maze wrote:
> Carlos Sousa <csousa@tvtel.pt> writes:
> > On Mon, 13 Oct 2003 08:30:23 +0100 Colin Watson wrote:
> >> Here's a little expression that strips off any trailing ".<extension>"
> >> from $1 and tacks on ".wav".
> >> 
> >>   "${1%.*}.wav"
> >
> > That's much better, no dependency on yet another utility, so more portable
> > code.
> 
> Not really; as was noted, the expression is bash-specific, and lots of
> non-Linux Unices don't have bash.

No, I noted that some other similar constructs you'll find in the same
section in the bash documentation are bash-specific. The expression I
gave is portable POSIX shell.

(It's true that it won't work on Solaris' /bin/sh, which is notoriously
non-POSIX. There's a POSIX shell lying around somewhere even on those
systems that you can use.)

Cheers,

-- 
Colin Watson                                  [cjwatson@flatline.org.uk]



Reply to: