Learning Bash: Quoting spaces
From: Sak (sak_at_invalid.address)
Date: 09/30/03
- Next message: Eric Moors: "Re: OT crossposting"
- Previous message: Jurjen Oskam: "Re: AIX 5.2: problem with here documents in ksh93"
- Next in thread: Stephane CHAZELAS: "Re: Learning Bash: Quoting spaces"
- Reply: Stephane CHAZELAS: "Re: Learning Bash: Quoting spaces"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Sep 2003 23:20:40 -0700
Everyone,
I'm working through O'Reilly's 'Learning the bash shell' and have run into
some questions. Here's the first one:
The following function is offered in Chapter 4
pushd ()
{
dirname=$1
DIR_STACK="$dirname ${DIR_STACK:-$PWD' '}"
cd ${dirname:?"missing directory name."}
echo "$DIR_STACK"
}
When I run this, the first directory that gets pushed onto the stack gets a
literal ' ' at the end of it, while the subsequent directories pushed onto
the stack do not. Like this...
/home/sak/wip/composition/ /home/sak/wip/lup/ /home/sak' '
I've managed to figure out that if I remove the strong quotes from around
the space, like this...
DIR_STACK="$dirname ${DIR_STACK:-$PWD }
...I get the desired result. I was just wondering why? In the previous
case, why did the literal quotes only end with the first item pushed onto
the stack, and not the rest?
-- Thanks, Sak.
- Next message: Eric Moors: "Re: OT crossposting"
- Previous message: Jurjen Oskam: "Re: AIX 5.2: problem with here documents in ksh93"
- Next in thread: Stephane CHAZELAS: "Re: Learning Bash: Quoting spaces"
- Reply: Stephane CHAZELAS: "Re: Learning Bash: Quoting spaces"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|