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

Re: not in X. man command does not respect set bell-style visible



On 01/03/12 20:40, Claudius Hubig wrote:
Andrei POPESCU<andreimpopescu@gmail.com>  wrote:
On Jo, 01 mar 12, 18:02:40, Claudius Hubig wrote:

->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->
#!/bin/sh
/bin/less -q $*

I've read somewhere that "$@" (including the quotes) is safer in such
situations.

That’s also what keeps lingering in the back of my head. However, I
cannot recall the reasons why $* would be unsafe. Unfortunately,
googling for either $* or $@ is not exactly…helpful.

Maybe you have a link or a hint to a man page regarding this topic?
bash(1) does not appear to mention $@.

The "$@" form preserves quoted arguments. This script will demonstrate:

#!/bin/bash

for i in $*
do
  echo "Arg1: $i"
done

for i in "$@"
do
  echo "Arg2: $i"
done

$ ./myscript 1 2 3 "4 5" 6

Arg1: 1
Arg1: 2
Arg1: 3
Arg1: 4
Arg1: 5
Arg1: 6
Arg2: 1
Arg2: 2
Arg2: 3
Arg2: 4 5
Arg2: 6

Note the "4 5" on the second set of args
--
Dom


Reply to: