Page MenuHomeFreeBSD

Lua version of @shell

Authored by bapt on Oct 2 2020, 8:23 AM.



Bonus it manipulates less /etc/shell only adding a line if needed

Diff Detail

rP FreeBSD ports repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

bapt requested review of this revision.Oct 2 2020, 8:23 AM

Use variable when possible

Use a buffer when deleting which avoid some syscalls and a temporary file

35 ↗(On Diff #77879)

Why == in the post-install and ~= here?

kevans added inline comments.
35 ↗(On Diff #77879)

This one is rewriting all the lines that arent' the shell_path, the other one is bailing out as soon as we find shell_path

35 ↗(On Diff #77879)

Mmmm, I fail to see where this answers my question.

35 ↗(On Diff #77879)

So on deinstall we bufferize the content of /etc/shells for all lines except the one we want to possibility remove.

If the shell we are interested in is found we overwrite /etc/shells if not we just drop the buffer ;)

on install this is this opposite we append our new shell only if we haven't already found it in existing /etc/shells

35 ↗(On Diff #77879)

No, I get your point about what post-install and pre-deinstall do, I did the first time around.
What about my question?

35 ↗(On Diff #77879)

Maybe I was not clear enough, doing if <not> ( sonething ) is ok, but doing if <not> (something) else (something else) is an anti-pattern, if there is an else, the test must be a positive thing and the clauses switched, otherwise it gets hard on the brain.

bapt marked 5 inline comments as done.Oct 15 2020, 6:37 AM
bapt added inline comments.
35 ↗(On Diff #77879)

Right ok, now I understand what you mean makes sense, let me fix that ;)

This revision is now accepted and ready to land.Oct 21 2020, 3:59 PM
This revision was automatically updated to reflect the committed changes.
bapt marked an inline comment as done.