219 reputation
15
bio website etalabs.net
location
age
visits member for 3 years, 3 months
seen 3 hours ago

Jun
10
comment Will Linux start killing my processes without asking me if memory gets short?
Citation: kernel.org/doc/Documentation/vm/overcommit-accounting
Jun
10
comment Will Linux start killing my processes without asking me if memory gets short?
Your understanding of the different values is wrong. 2 turns off overcommit off completely. 0 is the traditional "off" setting that doesn't really turn it off. 1 allows unlimited overcommit.
May
29
comment Is there a way in Linux to have one non root user check if another non root user has permissions to a folder / file?
Indeed, access is almost always a bug. It's subject to TOCTOU races and it uses the real uid/gid rather than the effective (or, if it's set differently, the Linux-specific fsuid/fsgid) uid/gid to determine permissions, which is almost never what you want unless they all happen to be equal.
May
26
comment Can the /home folder in Linux contain anything else but user folders?
@JamesN: If the other HD is formatted for use by windows, the problem is not going to be what it contains, but the fact that it's unsuitable for many uses that applications might expect to work. For instance, lacking symlink and hardlink support, case-sensitive filenames, fifos, unix sockets, ...
May
13
comment Why *not* parse `ls`?
@mikeserv: Then tell me what you want me to demonstrate. Patrick already gave you examples of directory contents which your method fails to parse (because they are indistinguishable by it). For any method you're using (please pick one for the sake of being specific) I'm happy to provide you a trivial example of a directory it fails to properly parse. The fact that you can construct specific examples which you think are "hard" and successfully parse them has no bearing on whether your method works in general.
May
13
comment Why *not* parse `ls`?
@mikeserv: The set command, like all commands to the shell, receives a list of arguments (ala argv[]) that come from shell words on the original command line. set itself does not do any word splitting. This is all described in POSIX XCU Chapter 2. Word-splitting is applied to the command line for set, like any other command, but it happens before glob expansion.
May
13
comment Why *not* parse `ls`?
@mikeserv: No, I just gave the most trivial example to explain the point that concatenation does not occur. The correct usage of set -- with globs also avoids any concatenation and word splitting. The incorrect usage of set -- with the output of ls does involve concatenation (inherent in the way ls writes output: as a stream of bytes, not a list of strings) and word splitting.
May
13
comment Why *not* parse `ls`?
@mikeserv: No it doesn't. I think this is the core of your misunderstanding. The shell never concatenates the filenames to begin with. In the shell, globs expand each result to a separate shell word. Thus usages like for i in * ; do ... ; done are safe, whereas usages like for i in $(echo *) ; do ... ; done are not (the latter has a concatenation step followed by a separate word-splitting step).
May
13
comment Why *not* parse `ls`?
@mikeserv: Your claim is simply wrong. If you have a sequence of strings and you concatenate them using a separator that can appear in the individual strings, there is no way to recover the original list of strings. To solve this problem you would need a reversible form of escaping, which ls does not provide. If it did provide such a feature you could write a very complex script to recover the filenames, but it's utter nonsense when the shell gives you a trivially-correct way to do the same thing with no danger of misinterpreting the results.
May
13
comment Why *not* parse `ls`?
@mikeserv: You have a stream of text produced by ls that can contain any bytes except the null byte or the slash. There is fundamentally no way to recover that into a list of filenames. The transformation ls does is non-reversible, even if it doesn't replace any nonprintable characters. When it replaces non-printable characters, you're in an even worse situation.
May
13
comment Why *not* parse `ls`?
@mikeserv: It's not misinformation. It's 100% correct. The fact that you refuse to believe it does not change the fact that it's correct.
May
12
comment Prevent hanging of “echo STRING > fifo” when nothing is reading that FIFO
Also, OP wants to buffer data in the pipe (until it fills up) rather than blocking when there's no reader, an easy way to achieve this is simply to have the script itself hold the fifo open for reading, but never actually read from it. (e.g. exec 3<fifo).
May
12
comment Prevent hanging of “echo STRING > fifo” when nothing is reading that FIFO
Storing state? You mean the absence/presence of a reader? That's part of the state of the fifo; any attempt to store it outside would be bogus and would be subject to race conditions.
May
12
comment Prevent hanging of “echo STRING > fifo” when nothing is reading that FIFO
I don't think this is a reasonable answer. It will just result in a huge number of stuck echo processes lying around. (Unlike in OP's original example, they will be separate processes since they're backgrounded.) Instead some mechanism is needed to immediately produce a failure when no reader is present.
May
12
comment Why *not* parse `ls`?
-1 for using a question to pick an argument. All of the reasons parsing ls output is wrong were covered well in the original link (and in plenty of other places). This question would have been reasonable if OP were asking for help understanding it, but instead OP is simply trying to prove his incorrect usage is ok.
Jul
3
comment coreutils that are utf aware?
It would be worth filing a bugreport (even if it ends up being a duplicate) to annoy the coreutils maintainers into actually fixing bugs like this, rather than just adding stupid hacks and toy utilities that nobody needs...
May
7
comment dd vs cat — is dd still relevant these days?
GNU implementation of...? head -c 1?
May
7
comment dd vs cat — is dd still relevant these days?
One more special use: dd can read binary data from nonseekable file descriptors without potentially destroying unread data due to stdio buffering. See here for an example: etalabs.net/sh_tricks.html
May
7
comment What's the reason that “rm -rf a/b” says “a/b is not empty”?
The && should be ; or else ls failure will prevent the script from exiting.
Apr
22
comment Is there a version of Wine that actually runs mainstream chat clients?
Thanks, I'll check it out. It may be a good choice for Google Talk, but it definitely won't solve the QQ or Skype problem.