Add an installation script #3
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Copying snippets from the README is uncomfortable and laborious. It also wastes a lot of space in the document.
This will be a POSIX sh script.
Check the SHELL environment variable and install sdn directly into the user's rc file. Make it possible to specify the shell's name explicitly (
-s bash), as well as the path (-f /etc/bash.bashrc). If the path is a dash (-f-), write the snippet to the standard output. Of course, add a help option. Use agetopts s:f:h optloop, which is POSIX-compatible and works with dash(1). Install the script.Wrap the snippets in a pair of detection comments (
# sdn-install begin..# sdn-install endshould be obvious enough and portable) and try to replace the contents--sed(1) may be used for this.sed -imay not be safe and we should retain permissions. Perhaps use:cp -p -- "$rc" "$rc.sdn.new",sed < "$rc" > "$rc.sdn.new",mv -- "$rc.sdn.new" "$rc". It copies data unnecessarily but it is portable (--attributes-onlyis GNU), unlike even stat(1).Compare
$(basename "$SHELL")with$(ps -p $$ -o ppid= | xargs ps -o comm= -p)and display an error on mismatch--the user will have to specify the shell manually in this case. Naturally, error out if the shell is not supported.It might be a good idea to export an environment variable and make sdn not output its variables if it's missing.
Add an instalation scriptto Add an installation script