Re: [gentoo-user] Re: FIXED 3D
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
Re: [gentoo-user] Re: FIXED 3D
-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-
Re: [gentoo-user] Re: FIXED 3D
On Thu, 08 Oct 2009 22:22:05 -0400, Jonathan Callen 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
[gentoo-user] Re: FIXED 3D
-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-
Re: [gentoo-user] Re: FIXED 3D
On Thu, 8 Oct 2009 19:33:01 +0100, 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 :) > > 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
Re: [gentoo-user] Re: FIXED 3D
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 . signature.asc Description: PGP signature
[gentoo-user] Re: FIXED 3D
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.
Re: [gentoo-user] Re: FIXED 3D
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
[gentoo-user] Re: FIXED 3D
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.
[gentoo-user] Re: FIXED 3D
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? :-/
Re: [gentoo-user] Re: FIXED 3D
On Thu, Oct 8, 2009 at 12:14 PM, Alan McKinnon 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 > >
Re: [gentoo-user] Re: FIXED 3D
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
Re: [gentoo-user] Re: FIXED 3D
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. -- Neil Bothwick Beware! The end is... signature.asc Description: PGP signature
[gentoo-user] Re: FIXED 3D
On 10/08/2009 06:28 PM, James wrote: One final question. When I run this command: emerge -1 $(qlist -I x11-drivers) I get this error: 'x11-drivers/ati-drivers' is not a valid package atom Please check ebuild(5) for full details. Try: emerge -1 $(qlist -I x11-drivers) And it's usually quicker to type with backticks instead of $(): emerge -1 `qlist -IC x11-drivers` Note: not single-quotes ('), but backticks (`). It's usually the key above TAB and to the left of 1.
[gentoo-user] Re: FIXED 3D
Jesús Guerrero terra.es> writes: > Probably the colors screwing everything, as always. Try searching the > qlist man page for something like --nocolor or --color=never. Yep: emerge -1 $(qlist -IC x11-drivers) works just fine thx James
Re: [gentoo-user] Re: FIXED 3D
On Thu, 8 Oct 2009 15:28:12 + (UTC), James wrote: > Jesús Guerrero terra.es> writes: > > >> You can't since you want to use ati-driver/fglrx. The fglrx is not part >> of >> the kernel, it's only shipped in the form of a binary-only closed source >> kernel module. fglrx doesn't need (and most likely will fail as you see) >> the in-kernel radeon drm driver. So, either disable radeon AND drm in >> your >> kernel, or build them as modules and make sure that they are not loaded >> before you try to load fglrx. > > > As usually Volker was right. Thanks for this explanation > With a mixture of open sourced and ati-driver systems, > sometimes I get confused.. or careless. > > > One final question. When I run this command: > emerge -1 $(qlist -I x11-drivers) > > I get this error: > 'x11-drivers/ati-drivers' is not a valid package atom > Please check ebuild(5) for full details. > > > yet 'emerge x11-drivers/ati-drivers' > works fine as a one line command > > > Is this a bug? My bad (syntax)? Probably the colors screwing everything, as always. Try searching the qlist man page for something like --nocolor or --color=never. -- Jesús Guerrero
[gentoo-user] Re: FIXED 3D
Jesús Guerrero terra.es> writes: > You can't since you want to use ati-driver/fglrx. The fglrx is not part of > the kernel, it's only shipped in the form of a binary-only closed source > kernel module. fglrx doesn't need (and most likely will fail as you see) > the in-kernel radeon drm driver. So, either disable radeon AND drm in your > kernel, or build them as modules and make sure that they are not loaded > before you try to load fglrx. As usually Volker was right. Thanks for this explanation With a mixture of open sourced and ati-driver systems, sometimes I get confused.. or careless. One final question. When I run this command: emerge -1 $(qlist -I x11-drivers) I get this error: 'x11-drivers/ati-drivers' is not a valid package atom Please check ebuild(5) for full details. yet 'emerge x11-drivers/ati-drivers' works fine as a one line command Is this a bug? My bad (syntax)? James