From: Koichi Murase Date: Tue, 3 Jun 2025 10:29:06 +0000 (+0900) Subject: bash-completion: prefer "builtin cd" to "cd" to avoid aliases X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1b356525c6824ec573b4fd3cf2a65585102cc641;p=thirdparty%2Futil-linux.git bash-completion: prefer "builtin cd" to "cd" to avoid aliases The command "cd" is also often aliased, so we should use "builtin cd" to make sure to use the built-in version of "cd". --- diff --git a/bash-completion/blkid b/bash-completion/blkid index ce122b3d9..c5b1ed889 100644 --- a/bash-completion/blkid +++ b/bash-completion/blkid @@ -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') diff --git a/bash-completion/choom b/bash-completion/choom index 7e16df17a..fd31d9698 100644 --- a/bash-completion/choom +++ b/bash-completion/choom @@ -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 ;; diff --git a/bash-completion/chrt b/bash-completion/chrt index b59d73613..3ca13fc05 100644 --- a/bash-completion/chrt +++ b/bash-completion/chrt @@ -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 diff --git a/bash-completion/coresched b/bash-completion/coresched index 3a14c5080..4629ab4f1 100644 --- a/bash-completion/coresched +++ b/bash-completion/coresched @@ -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 diff --git a/bash-completion/lsns b/bash-completion/lsns index c7518bacb..7269ae652 100644 --- a/bash-completion/lsns +++ b/bash-completion/lsns @@ -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') diff --git a/bash-completion/nsenter b/bash-completion/nsenter index 41c4cde09..1acc764ad 100644 --- a/bash-completion/nsenter +++ b/bash-completion/nsenter @@ -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 ;; diff --git a/bash-completion/prlimit b/bash-completion/prlimit index fc60c6461..276d57770 100644 --- a/bash-completion/prlimit +++ b/bash-completion/prlimit @@ -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 ;; diff --git a/bash-completion/renice b/bash-completion/renice index 2495f3785..88b9ca02d 100644 --- a/bash-completion/renice +++ b/bash-completion/renice @@ -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 ;; diff --git a/bash-completion/rtcwake b/bash-completion/rtcwake index cdee2f3d3..026729dbb 100644 --- a/bash-completion/rtcwake +++ b/bash-completion/rtcwake @@ -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 ;; diff --git a/bash-completion/setarch b/bash-completion/setarch index 9546eb292..992b12ca8 100644 --- a/bash-completion/setarch +++ b/bash-completion/setarch @@ -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') diff --git a/bash-completion/taskset b/bash-completion/taskset index 7c9a7bd54..407edc4ed 100644 --- a/bash-completion/taskset +++ b/bash-completion/taskset @@ -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 ;; diff --git a/bash-completion/uclampset b/bash-completion/uclampset index 87b5b378f..3cd5631ab 100644 --- a/bash-completion/uclampset +++ b/bash-completion/uclampset @@ -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