Re: quoting pathnames with spaces
On Sun, 20 Aug 2006 20:38:28 -0500, Charles Russell wrote:
> Is there some way to define macro WPATH so that I can just type cp file
> $WPATH and not have to type the quotes, cp file "$WPATH", every time?
> (I'm using cygwin and have to contend with Windows pathnames.) If
> possible, the same macro should be usable in Bourne shell scripts as
> well as at the command line.
You could define
r() {
c=1 cmd=
for i do
case $i in
£*) cmd="$cmd \"\${${i#£}}\"";;
*) cmd="$cmd \"\${$c}\"";;
esac
c=$(($c + 1))
done
eval "$cmd"
}
then:
r cp file £WPATH
--
Stephane
|