gui: Make $first a local variable of _get_subtree().
[gsu.git] / gui
diff --git a/gui b/gui
index 958c315..336d154 100644 (file)
--- a/gui
+++ b/gui
@@ -6,7 +6,7 @@ if [[ "$(type -t _gsu_setup)" != "function" ]]; then
        _gsu_setup
 fi
 
-export GSU_NODE_NAME_PATTERN='[a-zA-Z_]'
+_gsu_node_name_pattern='[a-zA-Z_]'
 
 _get_geometry()
 {
@@ -54,7 +54,7 @@ gsu_msgbox()
        rm -f "$tmp"
 }
 
-gsu_menu()
+_gsu_menu()
 {
        local header="${1:-root}"
        local items="$2"
@@ -72,14 +72,14 @@ gsu_menu()
 
 _get_level()
 {
-       local tmp="${1%%$GSU_NODE_NAME_PATTERN*}"
+       local tmp="${1%%$_gsu_node_name_pattern*}"
        result="${#tmp}"
 }
 
 _get_subtree()
 {
        local tree="$1" root="${2%/}"
-       local TAB='     '
+       local first TAB='       '
 
        first="$(grep -n "$TAB\{1,\}$root/" <<< "$tree")"
        [[ -z "$first" ]] && return
@@ -90,7 +90,7 @@ _get_subtree()
 
        #echo "line: $line_num, root: $root, indent level: $level"
        result="$(sed -e "1,${line_num}d;" <<< "$tree" \
-               | sed -e "/^$TAB\{1,$level\}$GSU_NODE_NAME_PATTERN/,\$d" \
+               | sed -e "/^$TAB\{1,$level\}$_gsu_node_name_pattern/,\$d" \
                | sed -e "/^$TAB\{$(($level + 2))\}/d")"
        ret="$level"
 }
@@ -99,7 +99,7 @@ _get_root_nodes()
 {
        local tree="$1" TAB='   '
 
-       result="$(grep "^${TAB}${GSU_NODE_NAME_PATTERN}" <<< "$tree")"
+       result="$(grep "^${TAB}${_gsu_node_name_pattern}" <<< "$tree")"
 }
 
 _browse()
@@ -108,7 +108,7 @@ _browse()
        local tree="$2" subtree="$3"
 
        while :; do
-               gsu_menu "$header" "$subtree"
+               _gsu_menu "$header" "$subtree"
                (($ret != 0)) && return
                [[ -z "$result" ]] && return
                if [[ "${result%/}" != "$result" ]]; then