]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash completions for IPC tools
authorPrasanna Paithankar <paithankarprasanna@gmail.com>
Sun, 2 Feb 2025 18:07:44 +0000 (23:37 +0530)
committerPrasanna Paithankar <paithankarprasanna@gmail.com>
Sun, 2 Feb 2025 18:07:44 +0000 (23:37 +0530)
Signed-off-by: Prasanna Paithankar <paithankarprasanna@gmail.com>
bash-completion/ipcmk
bash-completion/ipcrm
bash-completion/lsipc
sys-utils/ipcmk.1.adoc
sys-utils/ipcmk.c
sys-utils/ipcrm.c

index 696266cee77163dad08c15cedd8791fcf39d4183..0fbfaa4532675dd55a9339dea4386acfb93e9a42 100644 (file)
@@ -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
index 1ed03f9ee681734b0c3b8ed6a1074e50b95023c0..6f4870a607191533c225ad9af4fb22fa97fbccb2 100644 (file)
@@ -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
index a40fe428603f8d2b39e8654e125f73deea3df53e..047126a444d096d02b4c8b94c6349ab891397b55 100644 (file)
@@ -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
        "
index a4871f438a4e9eb8731dfc7a8f82add4c3d87c52..11e333387e7e7bdb3747bbf7ddc10b228f5a1e35 100644 (file)
@@ -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
 
index 7e48b270ebb2fd775c5c50d5604f912d657b42c4..5386d41e3802fe7c4b04f693c8b885fa334a57e3 100644 (file)
@@ -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 <errno.h>
@@ -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'},
index 2d080b007d322dc692ce509575bbd1f32762daa7..083d450cc1788e66ffe3be34a3efd8a03cca1478 100644 (file)
@@ -13,6 +13,9 @@
  *
  * 1999-04-02 frank zago
  * - can now remove several id's in the same call
+ * 
+ * 2025 Prasanna Paithankar <paithankarprasanna@gmail.com>
+ * - Added POSIX IPC support
  */
 #include <errno.h>
 #include <getopt.h>