Reputation
3,034
Top tag
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
6 18
Newest
 Nice Answer
Impact
~55k people reached

Jan
29
comment What happens when a non-root user sends signals to root user's process?
Other than SIGKILL, which is a special case and managed completely by the kernel, signals are merely a request. The receiving process can do anything they want with them.
Jan
29
comment Why do here-documents attempt shell substitution even on a commented line?
A # does not introduce a comment in a here document for the same reason it does not introduce a comment in "# $(echo foo)": a string is data, not code.
Jan
28
answered How to define alias for non interactive/non login shell?
Jan
27
comment How does the -d option to bash read work?
It's also worth nothing that read -d '' is a bit of a hack. You aren't specifying any character to look for as the end of a line (or possibly you are looking for the null character, ASCII 0, which due to implementation details cannot occur in a string), so read always just reads up to the end of its input, at which point it exits with a non-zero exit status because it never found the requested end-of-line character. This can be an issue if you are expecting read to succeed, such as if you are using set -e.
Jan
22
comment evaluation of arithmetic expansion in bash
Definitely worth a bug report to bug-bash@gnu.org; it's not fixed in 4.4, currently under development.
Jan
22
comment evaluation of arithmetic expansion in bash
/bin/echo preserves the difference, so it seems like output redirections for external commands happen in a subshell.
Jan
21
comment Recursive Function not Working
It's not ridiculous, but bash 4 introduced the ** pattern to avoid the need to write an explicit recursive function: for INDEX in **/*; do.
Jan
21
comment Why is subshell created by background control operator (&) not displayed under pstree
@HaukeLaging "But what process should that be if there is no external command to run?" A fork always creates a copy of the current process; there's no such thing as a process without a command. The shell starts any external command by forking, and the new copy of the shell then executes exec to replace itself with the new command.
Jan
21
revised What's wrong with this for loop in bash script?
Remove obsolete (and unnecessary) form of arithmetic expression
Jan
21
comment What's wrong with this for loop in bash script?
Note this will only work for integer-valued parameters.
Jan
20
comment Why is subshell created by background control operator (&) not displayed under pstree
& always causes the shell to fork. The forked shell process either handles the command itself (which is the case with exit), or makes a system call to (some form of) exec to replace itself with the given command.
Jan
18
comment In `dmesg | head`, (how) is dmesg being killed after 10 lines of output?
Technically, head terminates after it outputs 10 lines; it may consume more than 10 lines of input before doing so.
Dec
31
comment How bash changes environmental variables on-the-fly?
The environment is just part of the shell's memory space initialized by its parent.
Dec
31
answered How bash changes environmental variables on-the-fly?
Dec
31
comment How bash changes environmental variables on-the-fly?
bash is the current process; it's just changing its own memory space.
Dec
31
comment PS1 prompt to show elapsed time
@mikeserv If you unset SECONDS, it ceases to be updated. You can, however, reset it to another value to have it increment from there. SECONDS=0, for instance, makes it useful as a timer.
Dec
24
comment Comparison and brace expansion
Technically, there is no assignment operator. An assignment is a single string that contains an = and no surrounding whitespace; that's why x=3 is an assignment statement but none of x = 3, x= 3, or x =3 are.
Dec
23
comment Should variables be quoted when executed?
There is a reason why shells still support functions instead of simply stuffing commands into an array and executing it with ${mycmd[@]}.
Dec
21
comment Should I check bash version?
You don't have to modify it at all; just pattern match: if [[ $BASH_VERSION == 4.* ]];
Dec
17
comment Check Input Prior to Executing a “for loop”
@mikeserv bash borrowed (I assume) the select statement a very long time ago; it's present in bash 2.0 at least.