You are not logged in.

#1 2005-06-20 08:20:39

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,432
Website

var=$(uname -r) or var=`uname -r` ?

Are they the same?  Do they pose the same security risks in a PKGBUILD?

Offline

#2 2005-06-20 09:48:03

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: var=$(uname -r) or var=`uname -r` ?

I always used the latter one.... but i think they're both two ways of the same thing...

Offline

#3 2005-06-20 10:04:49

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: var=$(uname -r) or var=`uname -r` ?

ditto what iphitus said. I'm not sure how you mean with "security risk" though, what are you trying to do with it?

Offline

#4 2005-06-20 10:51:55

dtw
Forum Fellow
From: UK
Registered: 2004-08-03
Posts: 4,432
Website

Re: var=$(uname -r) or var=`uname -r` ?

if i put `rm -rf /` in it for example and the pkgbuild is parsed...

Offline

#5 2005-06-20 11:12:44

sudman1
Member
From: Huntingdon, UK
Registered: 2005-02-18
Posts: 143

Re: var=$(uname -r) or var=`uname -r` ?

They are the same, but IIRC $(...) is the preferred method


v/r
Suds

Offline

#6 2005-06-20 14:27:39

juergen
Developer
From: Frankfurt/Germany
Registered: 2005-04-11
Posts: 48
Website

Re: var=$(uname -r) or var=`uname -r` ?

sudman1 wrote:

They are the same, but IIRC $(...) is the preferred method

Not exactly the same. Try:

arg=foo
echo `echo $arg`
echo $(echo $arg)

This will yield:

foo
$arg

There is no difference when not using backslash escape character. Best check GNU Info manual.

Jürgen

Offline

#7 2005-06-20 14:39:34

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: var=$(uname -r) or var=`uname -r` ?

The $() syntax is bash, the backtick syntax is older sh, though of course bash supports it. THe reason bash included the $() syntax is that its easier to nest. So use $() when possible but if you need to deal with sh, use backticks.

Dusty

Offline

#8 2005-06-20 16:58:37

kpiche
Forum Fellow
From: Ottawa, ON, Canada
Registered: 2004-03-30
Posts: 246
Website

Re: var=$(uname -r) or var=`uname -r` ?

I understand that $() is preferred for bash.  Use:

arg=foo
echo `echo $arg`
echo $(echo $arg)

Offline

Board footer

Powered by FluxBB