[Ilugc] grep error

  • From: binand@xxxxxxxxx (Binand Sethumadhavan)
  • Date: Tue Mar 15 06:36:27 2005

On Mon, 14 Mar 2005 21:54:01 +0600, Haran Shivanan
<shivanan@xxxxxxxxxxxxxxxxx> wrote:

On Mon, 2005-03-14 at 11:50 +0530, gopu.bhaskar@xxxxxxxxx wrote:
Reason is the shell expanding * getting expanded to all the file names
in the dir and crossing the max limit of number of args.
Slightly OT:
I kind of find it annoying how globbing is done at the shell level and
not at the program level.
Yes, this makes it easier to write your program but at the same time,
this causes all sorts of unexpected results.

I find that this provides a consistent behaviour across all
applications. It also lets application programmers NOT to worry about
file globbing in their applications. Why should every single program
handle * or ~ or ? expansion? How about environment expansion (things
like vim $OLDPWD/somefile.txt)?

And if you REALLY hate shell filename globbing, you could turn it off
with set -f.

My favorite is how someone's directory had a file called "-r" (created
accidently by giving incorrect arguments to some other program) and the
user executed "rm *".
The shell expands the "*" and "-r" is treated as a command-line argument
causing rm to recursively delete everything.

All distros I have seen recently default to rm -i (usually via an
alias), so I don't think this is a real problem.

Binand

Other related posts: