* Re: [gentoo-user] Re: FIXED 3D
2009-10-08 18:33 ` Neil Bothwick
@ 2009-10-08 19:14 ` Alan McKinnon
2009-10-08 19:19 ` James Ausmus
2009-10-09 16:12 ` Alex Schuster
2009-10-08 19:34 ` Nikos Chantziaras
` (2 subsequent siblings)
3 siblings, 2 replies; 22+ messages in thread
From: Alan McKinnon @ 2009-10-08 19:14 UTC (permalink / raw
To: gentoo-user; +Cc: Neil Bothwick
On Thursday 08 October 2009 20:33:01 Neil Bothwick wrote:
> On Thu, 08 Oct 2009 18:54:26 +0300, Nikos Chantziaras wrote:
> > And it's usually quicker to type with backticks instead of $():
>
> But nowhere near as clear.
And it's quicker to type "$(" - muscle memory - than to do the whole hunt-
peek-peck thing to find the ` key - I can't touch type it, have to *look* for
it
:-)
> > Note: not single-quotes ('), but backticks (`). It's usually the key
> > above TAB and to the left of 1.
>
> I rest my case :)
>
> Note you can also nest commands when using $(), which you can't do with
> backticks.
That's neat. But,
please provide an example where an actual sane human would actually use it.
Coz I can't think of one...
--
alan dot mckinnon at gmail dot com
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [gentoo-user] Re: FIXED 3D
2009-10-08 19:14 ` Alan McKinnon
@ 2009-10-08 19:19 ` James Ausmus
2009-10-08 19:27 ` Nikos Chantziaras
2009-10-09 16:12 ` Alex Schuster
1 sibling, 1 reply; 22+ messages in thread
From: James Ausmus @ 2009-10-08 19:19 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]
On Thu, Oct 8, 2009 at 12:14 PM, Alan McKinnon <alan.mckinnon@gmail.com>wrote:
> On Thursday 08 October 2009 20:33:01 Neil Bothwick wrote:
> > On Thu, 08 Oct 2009 18:54:26 +0300, Nikos Chantziaras wrote:
> > > And it's usually quicker to type with backticks instead of $():
> >
> > But nowhere near as clear.
>
> And it's quicker to type "$(" - muscle memory - than to do the whole hunt-
> peek-peck thing to find the ` key - I can't touch type it, have to *look*
> for
> it
>
> :-)
>
> > > Note: not single-quotes ('), but backticks (`). It's usually the key
> > > above TAB and to the left of 1.
> >
> > I rest my case :)
> >
> > Note you can also nest commands when using $(), which you can't do with
> > backticks.
>
> That's neat. But,
>
> please provide an example where an actual sane human would actually use it.
> Coz I can't think of one...
>
>
I've used it before - I can't remember what is was for, but I do remember
using nested $() commands...
Isn't ` being deprecated (by BASH at least) anyway?
-James
> --
> alan dot mckinnon at gmail dot com
>
>
[-- Attachment #2: Type: text/html, Size: 1823 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* [gentoo-user] Re: FIXED 3D
2009-10-08 19:19 ` James Ausmus
@ 2009-10-08 19:27 ` Nikos Chantziaras
2009-10-08 20:02 ` Alan McKinnon
0 siblings, 1 reply; 22+ messages in thread
From: Nikos Chantziaras @ 2009-10-08 19:27 UTC (permalink / raw
To: gentoo-user
On 10/08/2009 10:19 PM, James Ausmus wrote:
> I've used it before - I can't remember what is was for, but I do
> remember using nested $() commands...
>
> Isn't ` being deprecated (by BASH at least) anyway?
Hopefully not! It's just two key presses to type "``". "$()" takes 4
(shift+4+9, command, shift+0).
What's easier than simply pressing one single key? :-/
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [gentoo-user] Re: FIXED 3D
2009-10-08 19:27 ` Nikos Chantziaras
@ 2009-10-08 20:02 ` Alan McKinnon
2009-10-08 20:09 ` Nikos Chantziaras
0 siblings, 1 reply; 22+ messages in thread
From: Alan McKinnon @ 2009-10-08 20:02 UTC (permalink / raw
To: gentoo-user; +Cc: Nikos Chantziaras
On Thursday 08 October 2009 21:27:57 Nikos Chantziaras wrote:
> On 10/08/2009 10:19 PM, James Ausmus wrote:
> > I've used it before - I can't remember what is was for, but I do
> > remember using nested $() commands...
> >
> > Isn't ` being deprecated (by BASH at least) anyway?
>
> Hopefully not! It's just two key presses to type "``". "$()" takes 4
> (shift+4+9, command, shift+0).
$() is more consistent with other syntax elements in bash, It's essentially
the same thing as evaluating a variable and inserting it's value. The ``
syntax is a wild anachronism from days long ago that is completely at odds
with everything else in the shell. Well, you can say that about many things in
bash, but that's not a good reason to not fix anything...
IIRC correctly it's not really deprecated either - that implies the thing will
go away some time. It's more "strongly advised not to use it"
>
> What's easier than simply pressing one single key? :-/
Ummm, not having to look for it and find it first before pressing it? How
about a keyboard that doesn't have it at all?
--
alan dot mckinnon at gmail dot com
^ permalink raw reply [flat|nested] 22+ messages in thread
* [gentoo-user] Re: FIXED 3D
2009-10-08 20:02 ` Alan McKinnon
@ 2009-10-08 20:09 ` Nikos Chantziaras
0 siblings, 0 replies; 22+ messages in thread
From: Nikos Chantziaras @ 2009-10-08 20:09 UTC (permalink / raw
To: alan.mckinnon; +Cc: gentoo-user
On 10/08/2009 11:02 PM, Alan McKinnon wrote:
> On Thursday 08 October 2009 21:27:57 Nikos Chantziaras wrote:
>> On 10/08/2009 10:19 PM, James Ausmus wrote:
>>> I've used it before - I can't remember what is was for, but I do
>>> remember using nested $() commands...
>>>
>>> Isn't ` being deprecated (by BASH at least) anyway?
>>
>> Hopefully not! It's just two key presses to type "``". "$()" takes 4
>> (shift+4+9, command, shift+0).
>
> $() is more consistent with other syntax elements in bash, It's essentially
> the same thing as evaluating a variable and inserting it's value. The ``
> syntax is a wild anachronism from days long ago that is completely at odds
> with everything else in the shell. Well, you can say that about many things in
> bash, but that's not a good reason to not fix anything...
>
> IIRC correctly it's not really deprecated either - that implies the thing will
> go away some time. It's more "strongly advised not to use it"
I think you're confusing script usage vs interactive CLI usage.
>> What's easier than simply pressing one single key? :-/
>
> Ummm, not having to look for it and find it first before pressing it?
That's true for every key. But I bet you learned how to do shift+4 to
get an $, right? Well, it's much easier to learn how to press ` to get
an... ` ;)
> How about a keyboard that doesn't have it at all?
Don't know, I've never saw one.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [gentoo-user] Re: FIXED 3D
2009-10-08 19:14 ` Alan McKinnon
2009-10-08 19:19 ` James Ausmus
@ 2009-10-09 16:12 ` Alex Schuster
1 sibling, 0 replies; 22+ messages in thread
From: Alex Schuster @ 2009-10-09 16:12 UTC (permalink / raw
To: gentoo-user
Alan McKinnon writes:
> On Thursday 08 October 2009 20:33:01 Neil Bothwick wrote:
> > On Thu, 08 Oct 2009 18:54:26 +0300, Nikos Chantziaras wrote:
> > > And it's usually quicker to type with backticks instead of $():
> >
> > But nowhere near as clear.
>
> And it's quicker to type "$(" - muscle memory - than to do the whole
> hunt- peek-peck thing to find the ` key - I can't touch type it, have
> to *look* for it
Uh...
> :-)
... okay :) I for myself was happy when I learnt that $() exists, and
prefer it over the backticks notation. Although it's more to type. But it
looks better, and I want my scripts to look good.
> > Note you can also nest commands when using $(), which you can't do
> > with backticks.
>
> That's neat. But,
>
> please provide an example where an actual sane human would actually use
> it. Coz I can't think of one...
Hey, I'm doing this all the time in my scripts. First example I found is
this, but there are many more:
total=$( mydf -2 "$dir" )
format=$( printf "%%%dd" $( echo $total | wc -c ) )
log 0 " Total: %s MB\n" "$( printf "$format" "$total" )"
log 0 " Used: %s MB\n" "$( printf "$format" "$( mydf -3 "$dir" )" )"
log 0 " Free: %s MB\n" "$( printf "$format" "$( mydf -4 "$dir" )" )"
That was before I knew about ${#total}, so in fact no nesting would be
required in line 2.
I think I also had tree levels of nesting somewhere, but that was too much
fpr Nedit's syntax highlighting, so I de-nested this a little.
Wonko the Sane
^ permalink raw reply [flat|nested] 22+ messages in thread
* [gentoo-user] Re: FIXED 3D
2009-10-08 18:33 ` Neil Bothwick
2009-10-08 19:14 ` Alan McKinnon
@ 2009-10-08 19:34 ` Nikos Chantziaras
2009-10-08 21:21 ` Neil Bothwick
2009-10-08 22:43 ` Jesús Guerrero
2009-10-09 2:22 ` Jonathan Callen
3 siblings, 1 reply; 22+ messages in thread
From: Nikos Chantziaras @ 2009-10-08 19:34 UTC (permalink / raw
To: gentoo-user
On 10/08/2009 09:33 PM, Neil Bothwick wrote:
> On Thu, 08 Oct 2009 18:54:26 +0300, Nikos Chantziaras wrote:
>
>> And it's usually quicker to type with backticks instead of $():
>
> But nowhere near as clear.
>
>> Note: not single-quotes ('), but backticks (`). It's usually the key
>> above TAB and to the left of 1.
>
> I rest my case :)
Why? It's one single key. Easy to remember. Nothing is easier than
one key instead of needing shift+4-shift+9 to produce "$(" :P
> Note you can also nest commands when using $(), which you can't do with
> backticks.
You can, but that is awkward (echo `echo \`echo \\\`ls\\\`\``). But for
a single, not-nested command, `` is lighting fast to type.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [gentoo-user] Re: FIXED 3D
2009-10-08 19:34 ` Nikos Chantziaras
@ 2009-10-08 21:21 ` Neil Bothwick
0 siblings, 0 replies; 22+ messages in thread
From: Neil Bothwick @ 2009-10-08 21:21 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]
On Thu, 08 Oct 2009 22:34:37 +0300, Nikos Chantziaras wrote:
> >> And it's usually quicker to type with backticks instead of $():
> >
> > But nowhere near as clear.
> >
> >> Note: not single-quotes ('), but backticks (`). It's usually the key
> >> above TAB and to the left of 1.
> >
> > I rest my case :)
>
> Why? It's one single key. Easy to remember. Nothing is easier than
> one key instead of needing shift+4-shift+9 to produce "$(" :P
>
But not as clear as stated above. I've lost count of the number of times
someone has posted a command, on this list or elsewhere, that uses
backticks, then had to explain what backticks are after the other person
used single quotes, not noticing the difference. You even had to explain
it yourself here, which took a lot more than an extra three keystrokes.
I'm not saying don't use backticks, I occasionally use them myself,
although I tend to automatically use $( these days, but using them on a
mailing list only causes confusion.
--
Neil Bothwick
This tagline SHAREWARE. Send .
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [gentoo-user] Re: FIXED 3D
2009-10-08 18:33 ` Neil Bothwick
2009-10-08 19:14 ` Alan McKinnon
2009-10-08 19:34 ` Nikos Chantziaras
@ 2009-10-08 22:43 ` Jesús Guerrero
2009-10-09 2:22 ` Jonathan Callen
3 siblings, 0 replies; 22+ messages in thread
From: Jesús Guerrero @ 2009-10-08 22:43 UTC (permalink / raw
To: gentoo-user
On Thu, 8 Oct 2009 19:33:01 +0100, Neil Bothwick <neil@digimed.co.uk>
wrote:
> On Thu, 08 Oct 2009 18:54:26 +0300, Nikos Chantziaras wrote:
>
>> And it's usually quicker to type with backticks instead of $():
>
> But nowhere near as clear.
>
>> Note: not single-quotes ('), but backticks (`). It's usually the key
>> above TAB and to the left of 1.
>
> I rest my case :)
>
> Note you can also nest commands when using $(), which you can't do with
> backticks.
Note also that some languages and keyboard layouts don't favor the use of
the backticks for this case. In Spanish keyboards, this characters: `´^¨
are dead keys (I think that's the correct term, not 100% sure), which means
they don't print anything until you press another key. That means that to
write `foo` I have to actually type `[space]foo`[space], or at least
``foo`` (press the key twice). An in any case it's just a matter of tastes.
Besides that, $() is far clearer, and it allows you to do things like this:
echo $(ls -l $(which tar))
Just an useless example. That, you can't do with backticks.
--
Jesús Guerrero
^ permalink raw reply [flat|nested] 22+ messages in thread
* [gentoo-user] Re: FIXED 3D
2009-10-08 18:33 ` Neil Bothwick
` (2 preceding siblings ...)
2009-10-08 22:43 ` Jesús Guerrero
@ 2009-10-09 2:22 ` Jonathan Callen
2009-10-09 2:56 ` Jesús Guerrero
2009-10-09 8:13 ` Neil Bothwick
3 siblings, 2 replies; 22+ messages in thread
From: Jonathan Callen @ 2009-10-09 2:22 UTC (permalink / raw
To: gentoo-user
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Neil Bothwick wrote:
> Note you can also nest commands when using $(), which you can't do with
> backticks.
You can nest commands with ``, it's just less intuitive; each of the
following are equivalent:
echo $(echo $(echo $(echo $(echo foo))))
echo $(echo $(echo $(echo `echo foo`)))
echo $(echo $(echo `echo \`echo foo\``))
echo $(echo `echo \`echo \\\`echo foo\\\`\``)
echo `echo \`echo \\\`echo \\\\\\\`echo foo\\\\\\\`\\\`\``
Yes, that is a *lot* of backslashes in the last one, which is why no one
nests that far with `` (personally, I always use $() instead of ``, but
that's mainly because I switched my escape for GNU screen from ^A to `).
- --
Jonathan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkrOnkwACgkQOypDUo0oQOqo4QCaA5iPSgyefVeK/clv3Tmb4bZh
QHcAnRbc/wufJ7NZlVfy7f3sACQm1ZoY
=ewZb
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [gentoo-user] Re: FIXED 3D
2009-10-09 2:22 ` Jonathan Callen
@ 2009-10-09 2:56 ` Jesús Guerrero
2009-10-09 8:13 ` Neil Bothwick
1 sibling, 0 replies; 22+ messages in thread
From: Jesús Guerrero @ 2009-10-09 2:56 UTC (permalink / raw
To: gentoo-user
On Thu, 08 Oct 2009 22:22:05 -0400, Jonathan Callen <abcd@gentoo.org>
wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Neil Bothwick wrote:
>> Note you can also nest commands when using $(), which you can't do with
>> backticks.
>
> You can nest commands with ``, it's just less intuitive; each of the
> following are equivalent:
Thank for calling my attention on that.
Yes, I know how it works. I rather meant that you can't nest the backticks
in a vanilla fashion, like with $(). Escaping the ticks you can do whatever
you want, it's just a matter of making sure the right thing reaches the
correct depth in a nested chain of shells, since each time that this kind
of substitution it happens in a new subshell.
$ pgrep bash | wc -l
6
$ echo $(pgrep bash | wc -l)
7
$ echo $(echo $(pgrep bash | wc -l))
8
I'll admit I didn't express it in the clearest way. However, this doesn't
solve the fact of the accents being dead keys in a lost (most?) languages
with a Latin alphabet, but English, nor the problem about the clarity
(though that's less an issue when you are working in command line, most
times anyway). I have no idea if the accent is a standard character in
every keyboard layout, so I am not sure that that is a valid argument on
any sane keyboard. I just checked and that accent is even part of the 7 bit
ascii table (dec 96), which is as minimal as you can get nowadays unless we
are speaking about some exotic embedded stuff or ancient device of the
caverns, and in that case, probably the same could apply to $, and even ()
:P
--
Jesús Guerrero
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [gentoo-user] Re: FIXED 3D
2009-10-09 2:22 ` Jonathan Callen
2009-10-09 2:56 ` Jesús Guerrero
@ 2009-10-09 8:13 ` Neil Bothwick
1 sibling, 0 replies; 22+ messages in thread
From: Neil Bothwick @ 2009-10-09 8:13 UTC (permalink / raw
To: gentoo-user
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, 08 Oct 2009 22:22:05 -0400, Jonathan Callen wrote:
> that's mainly because I switched my escape for GNU screen from ^A to `
That's a good idea, as I use ` a lot less than Ctrl-A I may do the same.
Then I'll have to override years opf muscle memory...
- --
Neil Bothwick
SCORE! Monkeys: one. Humans: zero.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.13 (GNU/Linux)
iEYEARECAAYFAkrO8KcACgkQum4al0N1GQOLQgCgomOE3LYWvnI4cMIYL2kNJe1Z
9FgAoJpYk6iVj0AYRVEXD0WV99qzvywB
=9yCA
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 22+ messages in thread