78,481 reputation
1083187
bio website
location European Union
age
visits member for 1 year, 11 months
seen 3 hours ago

3h
answered Succinct way to respond to user input?
4h
comment Accept only y or yes with a one-line regular expression
What flavour of regular expression (basic, extended, GNU basic, perl, vim, AT&T augmented...)? What will you use that with?
5h
answered Getting the process-id out of command launched with “su -c”
7h
awarded  Enlightened
9h
revised Combining multiple functions into a single bash script
added 8 characters in body
9h
awarded  Nice Answer
10h
revised Convert key=value blocks to CSV
added 408 characters in body
12h
comment What's the difference between $(stuff) and `stuff`?
Correction, only in (t)csh can they not be nested. (t)csh don't support $(...) though. They do support source (and not .) though.
12h
revised Command substitution declaration syntax in bash - which of these two is better practice?
added 158 characters in body
13h
comment Create an absolute symbolic link to the current directory
It all depends of context and what the OP wants to do. It's not that much about safety. A symlink can become broken at any moment, there's not much one can do about it.
13h
comment Create an absolute symbolic link to the current directory
If someone does the mv after you do ln, then you end up in the same situation. On the other hand, if he did cd /long/logical/path/to/some/directory, you don't want the link to point to /vg0/lv1/user2/app4 (the canonical path) as the link will point to the wrong place when /long/logical/path/to/some/directory points to somewhere else.
13h
answered bash: regular expressions in if expression
13h
comment bash: regular expressions in if expression
Depends on the version of bash (and on the compat31 option in newer bash versions).
13h
comment bash: regular expressions in if expression
+ is an extended regex operator, and some (the recent ones) versions of bash don't treat regexp operators as operators when quoted.
13h
revised Command substitution declaration syntax in bash - which of these two is better practice?
deleted 3 characters in body
13h
comment Command substitution declaration syntax in bash - which of these two is better practice?
Note that it's not only word splitting. It's word splitting and globbing (filename generation). Leaving a command/variable substitution unquoted is the split+glob operator. (that operator only applies in list contexts though, so not in the assignment to a scalar variable).
13h
comment Command substitution declaration syntax in bash - which of these two is better practice?
In the Bourne-shell family, only the Bourne shell doesn't support `...`. Even the original version of ash (initially a free reimplementation of the Bourne shell in 1989) supported $(...).
13h
answered Command substitution declaration syntax in bash - which of these two is better practice?
14h
comment Create an absolute symbolic link to the current directory
But what I'm saying is that the OP is as likely to want the old $PWD than some absolute path to the current working directory and that in several shells (ksh93, ash, yash), as explained there calling cd is not guaranteed to make $PWD or the output of pwd a path to the current directory. You're trying to guard against something that is not likely to happen, but in the first solution, that's not necessarily effective, and in the second, that's changing the behaviour.
14h
comment Create an absolute symbolic link to the current directory
The first one will not necessarily help in all shells (see this answer). The OP likely wants to use $PWD (the path he used to get there), rather than $(pwd -P) (the canonical path to the current directory). If $PWD no longer points to the current directory, then there's no saying that $(pwd -P) will in the next minute either.