diff options
author | Dmytro Meleshko <dmytro.meleshko@gmail.com> | 2019-10-28 12:53:36 +0200 |
---|---|---|
committer | Dmytro Meleshko <dmytro.meleshko@gmail.com> | 2019-10-28 12:59:58 +0200 |
commit | 4f6edb554e447eb8e10143879be6306e172630f3 (patch) | |
tree | a7af2ed46764090ce4186be28f30cc1915b81ccb | |
parent | fa670720e20212c70b19b1b7949ae0c36763c819 (diff) | |
download | ranger-4f6edb554e447eb8e10143879be6306e172630f3.tar.gz |
Apply requested changes to ranger.py and enforce full POSIX compliance
-rw-r--r-- | examples/bash_automatic_cd.sh | 7 | ||||
-rwxr-xr-x | ranger.py | 6 |
2 files changed, 6 insertions, 7 deletions
diff --git a/examples/bash_automatic_cd.sh b/examples/bash_automatic_cd.sh index 4e505327..5ba9d942 100644 --- a/examples/bash_automatic_cd.sh +++ b/examples/bash_automatic_cd.sh @@ -7,11 +7,10 @@ # To undo the effect of this function, you can type "cd -" to return to the # original directory. -ranger-cd() { - local temp_file chosen_dir - temp_file="$(mktemp -t "${0}.XXXXXXXXXX")" +ranger_cd() { + temp_file="$(mktemp -t "ranger_cd.XXXXXXXXXX")" ranger --choosedir="$temp_file" -- "${@:-$PWD}" - if chosen_dir="$(cat "$temp_file")" && [ -n "$chosen_dir" ] && [ "$chosen_dir" != "$PWD" ]; then + if chosen_dir="$(cat -- "$temp_file")" && [ -n "$chosen_dir" ] && [ "$chosen_dir" != "$PWD" ]; then cd -- "$chosen_dir" fi rm -f -- "$temp_file" diff --git a/ranger.py b/ranger.py index 57e2b082..7160160f 100755 --- a/ranger.py +++ b/ranger.py @@ -9,14 +9,14 @@ # default is simply "ranger". (Not this file itself!) # The other arguments are passed to ranger. """": -temp_file="$(mktemp)" +temp_file="$(mktemp -t "ranger_cd.XXXXXXXXXX")" ranger="${1:-ranger}" if [ -n "$1" ]; then - shift + shift fi "$ranger" --choosedir="$temp_file" -- "${@:-$PWD}" return_value="$?" -if chosen_dir="$(cat "$temp_file")" && [ -n "$chosen_dir" ]; then +if chosen_dir="$(cat -- "$temp_file")" && [ -n "$chosen_dir" ] && [ "$chosen_dir" != "$PWD" ]; then cd -- "$chosen_dir" fi rm -f -- "$temp_file" |