Re:Linux containers in 500 lines of code (2016)
by _zer0 on Tuesday February 04, 2020 @03:57PM
(#22240876)
Only the first few lines of the script look dense. Everything else looks normal to me.
[ Parent
| on HN ]
Re:Linux containers in 500 lines of code (2016)
by fwip on Tuesday February 04, 2020 @04:25PM
(#22241155)
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}'
)"
Re:Linux containers in 500 lines of code (2016)
by travbrack on Tuesday February 04, 2020 @09:32PM
(#22243478)
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.
Re:Linux containers in 500 lines of code (2016)
by stingraycharles on Tuesday February 04, 2020 @04:41PM
(#22241298)
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.
Re:Linux containers in 500 lines of code (2016)
by cyansmoker on Tuesday February 04, 2020 @06:52PM
(#22242470)
Can confirm. The bocker code (incl. my modest contributions) was targeted towards showing that the Linux toolbox was available and scriptable.