96,184 reputation
12114239
bio website
location European Union
age
visits member for 2 years, 3 months
seen 18 mins ago

7m
comment Switch to parent shell without logging out
@nyuszika7h, $$ may be readonly, but IFS is not. Try IFS=0123456789; suspend in ksh for instance.
9m
comment Switch to parent shell without logging out
Note that there's no guarantee that 19 will be the number of SIGTSTP. Use kill -s TSTP or kill -s STOP (TSTP can be trapped or ignored, STOP cannot).
10m
comment Switch to parent shell without logging out
bash does not trap CTRL-Z, when you press CTRL-Z, your terminal emulator sends a ^Z character (0x1a) to the master side of the pty device. The line discipline of the pty driver then sends SIGTSTP to the foreground process group of the terminal. Until then bash is not involved at all. That SIGTSTP may cause the process group leader to suspend and then the wait() that bash does on it will return.
16m
comment Switch to parent shell without logging out
@nyuszika7h, not-quoting variables is the split+glob operator. It makes no sense at all to invoke it here. The behaviour of the split part depends on the current value of $IFS. See also Security implications of forgetting to quote a variable in bash/POSIX shells.
16h
comment Filtering invalid utf8
Sorry, my bad, the behaviour is unspecified in POSIX since grep is a text utility (only expected to work on text input), so I suppose GNU grep's behaviour is as valid as any here.
17h
comment Switch to parent shell without logging out
@Mikel, zsh or csh, tcsh, or bash, or the Bourne shell or ksh... (in ksh, suspend is an alias for 'kill -s STOP $$' (note the bug with the missing quotes around $$)).
17h
comment Filtering invalid utf8
The python 2 one fails to flag UTF-8 encoded UTF-16 surrogate non-characters (at least with 2.7.6).
17h
comment Filtering invalid utf8
Except for -a, that's required to work by POSIX. However GNU grep at least fails to spot the UTF-8 encoded UTF-16 surrogate non-characters or codepoints above 0x10FFFF.
18h
comment What is the correct syntax for cloning a ntfs partition to a sparse file on another ntfs drive?
Use ntfsclone which only copies the allocated sectors.
1d
comment calendar to check the date and then search 3 months back and add up the days of those months?
Note that that syntax is zsh, not bash. In bash, you need to quote variables and arithmetic expansions.
1d
comment calendar to check the date and then search 3 months back and add up the days of those months?
For GNU date, 3 months ago on 2014-05-31 is 2014-03-03. You'll also be off by one day when across one of the DST shifts in timezones where they apply. For instance, there are 89 days between 2014-02-21 and 2014-05-21, but your solution would report 88 in most timezones that change their clock for daylight saving.
1d
comment calendar to check the date and then search 3 months back and add up the days of those months?
What should the result be on the 31st of May?
1d
comment Can Process id and session id of a daemon differ?
It's also common practice to fork after the setsid to avoid being a session leader, so that if ever the process opens a file and that file happens to be a tty device and you forgot to pass the the O_NOCTTY flag, it doesn't end up controlling the terminal. (which is why it's not uncommon to have sid != pid for a daemon, for instance Debian's start-stop-daemon -b does that).
1d
comment Replace uppercase to lowercase except first letter of each word in specific line
@MERose, you may have an old version of GNU sed that doesn't recognise \w. Try by replacing it with [:alnum:].
1d
comment Is it possible to tell Xorg not to listen on the abstract socket
@MartinVegter, not sure now. It could have been because I wanted to capture the X11 protocol traffic from an application, and it's harder to do when it's done over an abstract socket.
2d
comment Finding the correct tmp dir on multiple platforms
Just use ${TMPDIR-/tmp} on Unix-likes. TMPDIR is there (by the system or administrator or user) to tell you when not to use /tmp for temporary files.
2d
comment How can I conditionally pass a subshell through 'time'?
+1 for the nice twisted piece of hackery though...
2d
comment Redirecting stdout to terminal and file without using a pipe?
Run the tee < my_fifo in background instead of your function in the second case.
2d
comment How can I conditionally pass a subshell through 'time'?
eval joins its args before executing which is what you are trying to do in a very convoluted way. I meant that _time 'local var=1; blah' would make that var local to that _time, or that _time 'echo "$#"' would print the $# of that _time function, not that of the caller.
2d
comment Dump network traffic of single application (strace-like)
Create a new network namespace for the application and capture all traffic in there may be an acceptable approach for some use cases as well.