Hacker News new | past | comments | ask | show | jobs | submit login

Stuff like https://github.com/p8952/bocker/blob/master/bocker#L94 is super dense.

I might write that something like:

    cid="$(
      ps o ppid,pid |
        grep "^$(
          ps o pid,cmd |
            grep -E "^\ *[0-9]+ unshare.*$1" |
            awk '{print $1}'
        )" |
        awk '{print $2}'
    )"



Maybe I've spent too much time writing one-liners in bash but I really prefer the original to yours. I can read the original much faster because it matches the pattern for how I write bash on the command line. Yours looks totally foreign to how bash is normally written. Not saying one is better than the other, just my personal preference.


I agree with you that their code is fairly dense, yours is overly verbose.

Having said that, looking at their code, I don’t get the impression they’re optimizing for LOC. There is plenty of verbosity and opportunity to remove lines of code if they wanted.


Can confirm. The bocker code (incl. my modest contributions) was targeted towards showing that the Linux toolbox was available and scriptable.


Dang, didn't expect the downvotes for sharing my bash coding style. :(


or maybe even cid=$(pgrep -P $(pgrep -f "unshare.*$1")).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: