]> Sergey Matveev's repositories - nnn.git/commitdiff
Guard against empty
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 11 Jan 2020 18:56:03 +0000 (00:26 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 11 Jan 2020 18:56:03 +0000 (00:26 +0530)
misc/quitcd/quitcd.bash
misc/quitcd/quitcd.fish
misc/quitcd/quitcd.zsh

index 203e613b40345b5f4120dd7499b79b3c90425fbe..edeb2db943a2bfc1a09cf989bcfced04b7d61f12 100644 (file)
@@ -1,7 +1,7 @@
 n ()
 {
     # Block nesting of nnn in subshells
-    if [ "${NNNLVL:-0}" -ge 1 ]; then
+    if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
         echo "nnn is already running"
         return
     fi
index ea6a1bdafcea66809ffdbd3583bf90d7e53e0d31..9b3061c4c0ef179330077a3425d7a2be55e7cfc0 100644 (file)
@@ -4,9 +4,11 @@
 
 function n --description 'support nnn quit and change directory'
     # Block nesting of nnn in subshells
-    if [ (expr $NNNLVL + 0) -ge 1 ]
-        echo "nnn is already running"
-        return
+    if test -n NNNLVL
+        if [ (expr $NNNLVL + 0) -ge 1 ]
+            echo "nnn is already running"
+            return
+        end
     end
 
     # The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
index 203e613b40345b5f4120dd7499b79b3c90425fbe..edeb2db943a2bfc1a09cf989bcfced04b7d61f12 100644 (file)
@@ -1,7 +1,7 @@
 n ()
 {
     # Block nesting of nnn in subshells
-    if [ "${NNNLVL:-0}" -ge 1 ]; then
+    if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
         echo "nnn is already running"
         return
     fi