aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsfm9
1 files changed, 7 insertions, 2 deletions
diff --git a/sfm b/sfm
index d35aac1..f08a055 100755
--- a/sfm
+++ b/sfm
@@ -1,5 +1,6 @@
#!/bin/sh
-# sfm - Simple File Manager in POSIX sh
+# sfm - Simple File Manager in POSIX sh (flicker-free)
+# version 0.3
# --- terminal control ---
tput_cmd() { command -v tput >/dev/null 2>&1 && tput "$@"; }
@@ -61,7 +62,11 @@ term_rows() { tput_cmd lines || echo 24; }
term_cols() { tput_cmd cols || echo 80; }
# --- state ---
-CWD="$PWD"; CWD=$(cd "$CWD" 2>/dev/null && pwd) || CWD="/"
+if [ -n "$1" ]; then
+ CWD=$(cd "$1" 2>/dev/null && pwd) || { printf 'sfm: %s: no such directory\n' "$1" >&2; exit 1; }
+else
+ CWD=$(cd "$PWD" 2>/dev/null && pwd) || CWD="/"
+fi
SEL=0
OFFSET=0
PREV_SEL=0