Re: Can $1 be set in a script?
- From: larryalk <nobody@xxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 14:21:00 GMT
On Thu, 30 Mar 2006 23:15:35 -0900, floyd@xxxxxxxxxx (Floyd L.
Davidson) wrote:
larryalk <nobody@xxxxxxxxxxx> wrote:
On Fri, 31 Mar 2006 01:35:57 -0500, Bill Marcum <bmarcum@xxxxxxxxx>
wrote:
something=${1:-"default string"}
Excellent point.
Bill I ran across this exact same construction before in connection
with an ~/.xinitrc script.
Would you please tell me what the syntax means of:
(1:-"default string")
It does exactly the same thing that the several lines of my code
did.
I _guess_ it represents a variable.
What does the colon and minus sign signify?
Why guess... you should read the man page for bash...
Start by reading the section titled "Parameter Expansion".
Thank you Floyd. I had been thinking of how to use Google to get a
handle on that but man bash explained it all.
This {1:-string} construct is going to be very handy.
After re-thinking about my subject "Can $1 be set in a script?" I
realize that I just wasn't thinking. Apparently I made a big fuss
over nothing.
It's easy to create
1=something
2=borrowed
echo $1 $2
something borrowed
Voila, $1 and $2 created where they didn't exist before.
But {1:-string} is even better.
Larry
--
My real sig is much better.
.
- References:
- Can $1 be set in a script?
- From: larryalk
- Re: Can $1 be set in a script?
- From: Chris F.A. Johnson
- Re: Can $1 be set in a script?
- From: larryalk
- Re: Can $1 be set in a script?
- From: Floyd L. Davidson
- Re: Can $1 be set in a script?
- From: Bill Marcum
- Re: Can $1 be set in a script?
- From: larryalk
- Re: Can $1 be set in a script?
- From: Floyd L. Davidson
- Can $1 be set in a script?
- Prev by Date: Re: KDE/X dual head issue
- Next by Date: Re: KDE/X dual head issue
- Previous by thread: Re: Can $1 be set in a script?
- Next by thread: Re: Can $1 be set in a script?
- Index(es):
Relevant Pages
|