]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: prefer "builtin cd" to "cd" to avoid aliases
authorKoichi Murase <myoga.murase@gmail.com>
Tue, 3 Jun 2025 10:29:06 +0000 (19:29 +0900)
committerKoichi Murase <myoga.murase@gmail.com>
Tue, 3 Jun 2025 10:29:14 +0000 (19:29 +0900)
The command "cd" is also often aliased, so we should use "builtin cd"
to make sure to use the built-in version of "cd".

12 files changed:
bash-completion/blkid
bash-completion/choom
bash-completion/chrt
bash-completion/coresched
bash-completion/lsns
bash-completion/nsenter
bash-completion/prlimit
bash-completion/renice
bash-completion/rtcwake
bash-completion/setarch
bash-completion/taskset
bash-completion/uclampset

index ce122b3d951ddbc929766cee88b9430974576fa5..c5b1ed8895b45edc5e125bdc512ede2cabf9b181 100644 (file)
@@ -25,11 +25,11 @@ _blkid_module()
                        return 0
                        ;;
                '-L'|'--label')
-                       COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-label/ 2>/dev/null && echo *)" -- $cur) )
+                       COMPREPLY=( $(compgen -W "$(builtin cd /dev/disk/by-label/ 2>/dev/null && echo *)" -- $cur) )
                        return 0
                        ;;
                '-U'|'--uuid')
-                       COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-uuid/ 2>/dev/null && echo *)" -- $cur) )
+                       COMPREPLY=( $(compgen -W "$(builtin cd /dev/disk/by-uuid/ 2>/dev/null && echo *)" -- $cur) )
                        return 0
                        ;;
                '-S'|'--size')
index 7e16df17a357d12b751d40ff8c9a1f421640efdf..fd31d96983030c1cfb0b83f175926f78cb129d46 100644 (file)
@@ -11,7 +11,7 @@ _choom_module()
                        ;;
                '-p'|'--pid')
                        local PIDS
-                       PIDS=$(cd /proc && echo [0-9]*)
+                       PIDS=$(builtin cd /proc && echo [0-9]*)
                        COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
                        return 0
                        ;;
index b59d73613d5ed8d4adbaf87f4ff592b9ed68e297..3ca13fc05711a7b7b0c713e9fe535dbcdfd1d31a 100644 (file)
@@ -42,7 +42,7 @@ _chrt_module()
        for i in ${COMP_WORDS[*]}; do
                case $i in
                '-p'|'--pid')
-                       COMPREPLY=( $(compgen -W "$(cd /proc && echo [0-9]*)" -- $cur) )
+                       COMPREPLY=( $(compgen -W "$(builtin cd /proc && echo [0-9]*)" -- $cur) )
                        return 0
                        ;;
                esac
index 3a14c5080b3ebdd667cceea51ae12d77836d3ea1..4629ab4f170f6b5a4573c8f3e4ce2b6d6af7081e 100644 (file)
@@ -13,7 +13,7 @@ _coresched_module()
   case $3 in
     "-s"|"--source"|"-d"|"--dest")
       local pids sorted_pids
-      pids=$(cd /proc && echo [0-9]*)
+      pids=$(builtin cd /proc && echo [0-9]*)
       sorted_pids=$(echo "${pids[@]}" | tr ' ' '\n' | sort -nr | tr '\n' ' ')
       COMPREPLY=( $(compgen -W "$sorted_pids" -- "$2") )
       return 0
index c7518bacbe766fafa3d6ddb0a655d680951f46ae..7269ae652e60005bd1f250604c5cc50f4229d98a 100644 (file)
@@ -22,7 +22,7 @@ _lsns_module()
                        return 0
                        ;;
                '-p'|'--task')
-                       COMPREPLY=( $(compgen -W "$(cd /proc && echo [0-9]*)" -- $cur) )
+                       COMPREPLY=( $(compgen -W "$(builtin cd /proc && echo [0-9]*)" -- $cur) )
                        return 0
                        ;;
                '-t'|'--type')
index 41c4cde099522f6be9146db346f185b68edbc7bb..1acc764ad09436db88681df4b78675d2fde31858 100644 (file)
@@ -15,7 +15,7 @@ _nsenter_module()
                        ;;
                '-t'|'--target')
                        local PIDS
-                       PIDS=$(cd /proc && echo [0-9]*)
+                       PIDS=$(builtin cd /proc && echo [0-9]*)
                        COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
                        return 0
                        ;;
index fc60c6461011bfb1766998ff2a2b6f4b940a58a9..276d57770b5d3d1a2f323e18c9b31754b0da58d5 100644 (file)
@@ -6,7 +6,7 @@ _prlimit_module()
        prev="${COMP_WORDS[COMP_CWORD-1]}"
        case $prev in
                '-p'|'--pid')
-                       PIDS=$(cd /proc && echo [0-9]*)
+                       PIDS=$(builtin cd /proc && echo [0-9]*)
                        COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
                        return 0
                        ;;
index 2495f37851cd7c6142b7a227ff94557d036fdad6..88b9ca02dc118088bfcbbc28faa30e9dd41ad8f2 100644 (file)
@@ -17,7 +17,7 @@ _renice_module()
                        ;;
                '-p'|'--pid')
                        local PIDS
-                       PIDS=$(cd /proc && echo [0-9]*)
+                       PIDS=$(builtin cd /proc && echo [0-9]*)
                        COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
                        return 0
                        ;;
index cdee2f3d35516e970ec4774cd03c2104416f12fc..026729dbbb4749d6176c4459ab62eb024459fe87 100644 (file)
@@ -13,7 +13,7 @@ _rtcwake_module()
                        ;;
                '-d'|'--device')
                        local RTC_DEVS
-                       RTC_DEVS=$(cd /sys/class/rtc/ && echo *)
+                       RTC_DEVS=$(builtin cd /sys/class/rtc/ && echo *)
                        COMPREPLY=( $(compgen -W "$RTC_DEVS" -- $cur) )
                        return 0
                        ;;
index 9546eb29245ab2fc3d1774ebf90d54571d16bffd..992b12ca86785781be449f8e744f96a82c11b582 100644 (file)
@@ -16,7 +16,7 @@ _setarch_module()
                        return 0
                        ;;
                '-p'|'--pid')
-                       COMPREPLY=( $(compgen -W "$(cd /proc && echo [0-9]*)" -- $cur) )
+                       COMPREPLY=( $(compgen -W "$(builtin cd /proc && echo [0-9]*)" -- $cur) )
                        return 0
                        ;;
                '--show')
index 7c9a7bd546a2a234871e72aa26c698d4abae4047..407edc4edca7b0856535fc8815e135bd65d75dc1 100644 (file)
@@ -25,7 +25,7 @@ _taskset_module()
                        # setting an affinity the optarg has to be cpu
                        # mask.  The following is good only for getting
                        # affinity.
-                       PIDS=$(cd /proc && echo [0-9]*)
+                       PIDS=$(builtin cd /proc && echo [0-9]*)
                        COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
                        return 0
                        ;;
index 87b5b378f4555834bc309e5ff3ca2b330601b7ad..3cd5631abd219274fb493fab2f6acbc550d0a0ee 100644 (file)
@@ -28,7 +28,7 @@ _uclampset_module()
        for i in ${COMP_WORDS[*]}; do
                case $i in
                '-p'|'--pid')
-                       COMPREPLY=( $(compgen -W "$(cd /proc && echo [0-9]*)" -- $cur) )
+                       COMPREPLY=( $(compgen -W "$(builtin cd /proc && echo [0-9]*)" -- $cur) )
                        return 0
                        ;;
                esac