Repository navigation
Run try command in the users shell of choice - #197
Conversation
| cleanup() { | ||
| cd / | ||
|
|
||
| if [ -d "$try_workspace" ]; then |
There was a problem hiding this comment.
We can drop this whole if---we don't need a try_workspace for this test.
| check_case "" "/bin/bash" "/bin/bash" "2" | ||
|
|
||
| if [ "$CI" = "true" ]; then | ||
| saved_shell=$(grep -e "^$LOGNAME" /etc/passwd | cut -d: -f7) |
There was a problem hiding this comment.
Do something like : ${LOGNAME=$(whoami)} first, since $LOGNAME doesn't seem to be set in CI here.
|
|
||
| if [ "$CI" = "true" ]; then | ||
| saved_shell=$(grep -e "^$LOGNAME" /etc/passwd | cut -d: -f7) | ||
| sudo apt install -y zsh |
There was a problem hiding this comment.
| sudo apt install -y zsh | |
| sudo apt-get install -y zsh |
There was a problem hiding this comment.
can we omit the installing of zsh part here, since not all runners/test distro will be debian based, and for other test deps we have always been just relying on the environment having it
Co-authored-by: Michael Greenberg <michael@greenberg.science>
Co-authored-by: Michael Greenberg <michael@greenberg.science>
Co-authored-by: Michael Greenberg <michael@greenberg.science>
|
|
||
| While using *try* you can choose to commit the result to the filesystem or completely ignore it without any side-effect to the main file system. | ||
|
|
||
| You can also choose your own shell when running *try*. |
There was a problem hiding this comment.
try will run your command within your login shell by default; you can override this by setting the TRY_SHELL variable.
mgree
left a comment
There was a problem hiding this comment.
Fundamentally fine---a few comment nits, and we need to fix the formatting.
|
|
||
| While using *try* you can choose to commit the result to the filesystem or completely ignore it without any side-effect to the main file system. | ||
|
|
||
| You can also choose your own shell when running *try*. *try* will run your command within your login shell by default; you can override this by setting the TRY_SHELL variable. |
There was a problem hiding this comment.
| You can also choose your own shell when running *try*. *try* will run your command within your login shell by default; you can override this by setting the TRY_SHELL variable. | |
| You can also choose your own shell when running *try*. *try* will run your command within your login shell by default; you can override this by setting the *TRY_SHELL* variable to the absolute path of a shell to use. |
|
|
||
| ################################################################################ | ||
| # Run a command (in `$@`) in an overlay (in `$SANDBOX_DIR`) | ||
| # Returns the shell try is currently running on |
There was a problem hiding this comment.
This isn't exactly the right description. Maybe:
| # Returns the shell try is currently running on | |
| # Tries to detect a setting for TRY_SHELL |
| [ -d "$SANDBOX_DIR" ] || error "could not find sandbox directory $SANDBOX_DIR" 2 | ||
| # Force absolute path | ||
| SANDBOX_DIR="$(cd "$SANDBOX_DIR" && pwd)" | ||
| #case TRY_SHELL set |
There was a problem hiding this comment.
Please try to keep formatting like other comments in the code. (There are a few others missing spaces after #.)
| #case TRY_SHELL set | |
| # case: TRY_SHELL set to an executable |
| ## Create a new sandbox if one was not given | ||
| SANDBOX_DIR="$(mktemp -d --suffix ".try-$EXECID")" | ||
| fi | ||
| #check if SHELL is set and is not fish |
There was a problem hiding this comment.
This comment is just translating the code to English---we expect someone reading this to understand the basics of the shell code anyway. The intent is more like:
| #check if SHELL is set and is not fish | |
| # use SHELL (if it's not fish) |
| error "given sandbox '$SANDBOX_DIR' is invalid" 1 | ||
| else | ||
| login_shell=$(grep "^$(whoami):" /etc/passwd | cut -d: -f7) | ||
| #echo "login_shell in try: $login_shell" |
There was a problem hiding this comment.
Please don't leave in your print debugs!
| #echo "login_shell in try: $login_shell" |
| try-summary -i "$IGNORE_FILE" "$SANDBOX_DIR" || return 1 | ||
| TRY_EXIT_STATUS=0 | ||
| } | ||
| if type try-summary >/dev/null 2>&1; then |
There was a problem hiding this comment.
Ditto... all these are showing whitespace-induced diffs. 😢
| (--) shift | ||
| try "$@";; | ||
| (*) try "$@";; | ||
| summary) |
There was a problem hiding this comment.
This was entirely reformatted... can you put it back the way it was, please?
Issue #7 says that we always run try in bin/sh. We want to allow the user to choose what shell try runs in or failing that picks a sane default.