Mailinglist Archive: opensuse (2740 mails)
|< Previous||Next >|
Re: [opensuse] bash - handling expansion of parameters on the command line?
- From: "Brian K. White" <brian@xxxxxxxxx>
- Date: Tue, 2 Dec 2008 16:00:57 -0500
- Message-id: <54592BBDDAFB4A4596AC1918A2A689F5@miata>
----- Original Message ----- From: "David C. Rankin" <drankinatty@xxxxxxxxxxxxxxxxxx>
To: "suse" <opensuse@xxxxxxxxxxxx>
Sent: Monday, December 01, 2008 9:25 PM
Subject: [opensuse] bash - handling expansion of parameters on the command line?
I have run across another quandary. I am trying to get a filespec from the
command line like:
You need to say
and file name expansion occurs before I can assign the filespec to a variable.
I want to be able to grab the 'file1*' filespec without having to require that
it be enclosed in single quotes (./scriptname 'file1*'). I'm using the filespec
Sorry, not an option.
The only way you can get the litteral string "file1*" passed is to prevent the interactive shell from expanding it before-hand.
The only ways to do this are:
This shouldn't be viewed as a limitation or hardship, but rather as an ability or a feature.
The ability to be precise.
Globbing is a very powerful and useful feature, and so it's active by default. But sometimes in some rare and special cases you don't want the globbing to occure, and so another feature is the ability to suspend the globbing from happening, and since no single way of doing something is always convenient, there is even at least the 3 different methods above to suspend the globbing.
In other words, I think it's a mistake to even try or want to avoid saying
That is the way the entire system works and as a unix shell user it should just be a natural part of the interface for you. You still need to use the same quoting and escaping syntax with every other program anyways, which means you still need know the times & places when globbing will happen and the times & places when you don't want it to happen.
If you are trying to make a program that other users will use who are not necessarily unix users and you don't want them to require them to be this savvy, you could make the script interactive. Then they would type in the filespec into a read command, and you can put a set -f in the script before the read, then they wouldn't have to do any special quoting.
Or you could make a seperate xterm/gnome-terminal/etc desktop icon that launches bash with -f so globbing is disabled for that window.
Brian K. White brian@xxxxxxxxx http://www.myspace.com/KEYofR
filePro BBx Linux SCO FreeBSD #callahans Satriani Filk!
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx
|< Previous||Next >|