From: Prasanna Paithankar Date: Sun, 2 Feb 2025 18:07:44 +0000 (+0530) Subject: bash completions for IPC tools X-Git-Tag: v2.42-start~54^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0f5e95f22866619c61eed8549c71accc8ab24beb;p=thirdparty%2Futil-linux.git bash completions for IPC tools Signed-off-by: Prasanna Paithankar --- diff --git a/bash-completion/ipcmk b/bash-completion/ipcmk index 696266cee..0fbfaa453 100644 --- a/bash-completion/ipcmk +++ b/bash-completion/ipcmk @@ -9,19 +9,30 @@ _ipcmk_module() COMPREPLY=( $(compgen -W "size" -- $cur) ) return 0 ;; + '-m'|'--posix-shmem') + COMPREPLY=( $(compgen -W "size" -- $cur) ) + return 0 + ;; '-S'|'--semaphore') COMPREPLY=( $(compgen -W "number" -- $cur) ) return 0 ;; + '-s'|'--posix-semaphore'|'-Q'|'--queue'|'-q'|'--posix-mqueue') + return 0 + ;; '-p'|'--mode') COMPREPLY=( $(compgen -W "mode" -- $cur) ) return 0 ;; + '-n'|'--name') + COMPREPLY=( $(compgen -W "name" -- $cur) ) + return 0 + ;; '-h'|'--help'|'-V'|'--version') return 0 ;; esac - COMPREPLY=( $(compgen -W "--shmem --semaphore --queue --mode --help --version" -- $cur) ) + COMPREPLY=( $(compgen -W "--shmem --posix-shmem --semaphore --posix-semaphore --queue --posix-mqueue --mode --name --help --version" -- $cur) ) return 0 } complete -F _ipcmk_module ipcmk diff --git a/bash-completion/ipcrm b/bash-completion/ipcrm index 1ed03f9ee..6f4870a60 100644 --- a/bash-completion/ipcrm +++ b/bash-completion/ipcrm @@ -6,32 +6,47 @@ _ipcrm_module() prev="${COMP_WORDS[COMP_CWORD-1]}" case $prev in '-m'|'--shmem-id') - KEYIDS="$(ipcs -m | awk '{if (3 < NR) {print $2}}')" + KEYIDS="$(lsipc -m | awk 'NR>1 {print $2}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; '-M'|'--shmem-key') - KEYIDS="$(ipcs -m | awk '{if (3 < NR) {print $1}}')" + KEYIDS="$(lsipc -m | awk 'NR>1 {print $1}')" + COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) + return 0 + ;; + '--posix-shmem') + KEYIDS="$(lsipc -M | awk 'NR>1 {print $1}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; '-q'|'--queue-id') - KEYIDS="$(ipcs -q | awk '{if (3 < NR) {print $2}}')" + KEYIDS="$(lsipc -q | awk 'NR>1 {print $2}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; '-Q'|'--queue-key') - KEYIDS="$(ipcs -q | awk '{if (3 < NR) {print $1}}')" + KEYIDS="$(lsipc -q | awk 'NR>1 {print $1}')" + COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) + return 0 + ;; + '--posix-mqueue') + KEYIDS="$(lsipc -Q | awk 'NR>1 {print $1}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; '-s'|'--semaphore-id') - KEYIDS="$(ipcs -s | awk '{if (3 < NR) {print $2}}')" + KEYIDS="$(lsipc -s | awk '{if (3 < NR) {print $2}}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; '-S'|'--semaphore-key') - KEYIDS="$(ipcs -s | awk '{if (3 < NR) {print $1}}')" + KEYIDS="$(lsipc -s | awk '{if (3 < NR) {print $1}}')" + COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) + return 0 + ;; + '--posix-semaphore') + KEYIDS="$(lsipc -S | awk 'NR>1 {print $1}')" COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) ) return 0 ;; @@ -42,16 +57,19 @@ _ipcrm_module() case $cur in '=') cur=${cur#=} - COMPREPLY=( $(compgen -W "shm msg sem" -- $cur) ) + COMPREPLY=( $(compgen -W "shm pshm msg pmsg sem psem" -- $cur) ) return 0 ;; esac OPTS=" --shmem-id --shmem-key + --posix-shmem --queue-id --queue-key + --posix-mqueue --semaphore-id --semaphore-key + --posix-semaphore --all= --verbose --help diff --git a/bash-completion/lsipc b/bash-completion/lsipc index a40fe4286..047126a44 100644 --- a/bash-completion/lsipc +++ b/bash-completion/lsipc @@ -9,6 +9,10 @@ _lsipc_module() COMPREPLY=( $(compgen -W "id" -- $cur) ) return 0 ;; + '-N'|'--name') + COMPREPLY=( $(compgen -W "name" -- $cur) ) + return 0 + ;; '-h'|'--help'|'-V'|'--version') return 0 ;; @@ -45,10 +49,14 @@ _lsipc_module() esac OPTS=" --shmems + --posix-shmems --queues + --posix-mqueues --semaphores + --posix-semaphores --global --id + --name --noheadings --notruncate --time-format @@ -62,6 +70,7 @@ _lsipc_module() --numeric-perms --raw --time + --shell --help --version " diff --git a/sys-utils/ipcmk.1.adoc b/sys-utils/ipcmk.1.adoc index a4871f438..11e333387 100644 --- a/sys-utils/ipcmk.1.adoc +++ b/sys-utils/ipcmk.1.adoc @@ -56,7 +56,8 @@ include::man-common/help-version.adoc[] == AUTHORS -mailto:hayden.james@gmail.com[Hayden A. James] +mailto:hayden.james@gmail.com[Hayden A. James], +mailto:paithankarprasanna@gmail.com[Prasanna Paithankar] == SEE ALSO diff --git a/sys-utils/ipcmk.c b/sys-utils/ipcmk.c index 7e48b270e..5386d41e3 100644 --- a/sys-utils/ipcmk.c +++ b/sys-utils/ipcmk.c @@ -14,9 +14,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include @@ -146,7 +146,7 @@ int main(int argc, char **argv) {"shmem", required_argument, NULL, 'M'}, {"posix-shmem", required_argument, NULL, 'm'}, {"semaphore", required_argument, NULL, 'S'}, - {"posix-semaphore", required_argument, NULL, 's'}, + {"posix-semaphore", no_argument, NULL, 's'}, {"queue", no_argument, NULL, 'Q'}, {"posix-mqueue", no_argument, NULL, 'q'}, {"mode", required_argument, NULL, 'p'}, diff --git a/sys-utils/ipcrm.c b/sys-utils/ipcrm.c index 2d080b007..083d450cc 100644 --- a/sys-utils/ipcrm.c +++ b/sys-utils/ipcrm.c @@ -13,6 +13,9 @@ * * 1999-04-02 frank zago * - can now remove several id's in the same call + * + * 2025 Prasanna Paithankar + * - Added POSIX IPC support */ #include #include