bug-bash
[Top][All Lists]
Advanced

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

Re: Avoid asterisk expansion when it selects "everything"


From: Bob Proulx
Subject: Re: Avoid asterisk expansion when it selects "everything"
Date: Wed, 13 Apr 2016 22:20:20 -0600
User-agent: Mutt/1.5.24 (2015-08-30)

Anis ELLEUCH wrote:
> I would like to ask if it is possible to disable expanding asterisk when it
> selects all entries ?

You ask if it is possible and the answer is no it is not possible.
Because the shell expands the "*" before it passes the result as
arguments to the rm command.  The rm command has no idea it was the
result of an expansion from a "*" wildcard.  The rm command simply
receives the list of files.

> Another idea: `*` and `/*` should not be interpreted and the user has to
> enter another sequence "more powerful" to emphasize selecting all entries (
> `^*` would it work just fine ?)

But then the same thing exists there.  If the user accidentally enters
that sequence then it is the same thing all over again.

If I am ever uncertain about a file glob expansion then I use echo
first to see what the expansion will do.  If dealing with dangerous
commands such as rm then it is wise to check twice before invoking.

  echo rm * .jpg

If you saw the result then you would fix it before invoking the
command for effect.  If the result is bad then correct it.  If the
result is good then remove the echo and run the command for effect.

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]