]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: Standardize fsck/mkfs file/device
authorKevin Locke <kevin@kevinlocke.name>
Thu, 19 Sep 2019 13:27:31 +0000 (07:27 -0600)
committerKevin Locke <kevin@kevinlocke.name>
Thu, 19 Sep 2019 13:27:31 +0000 (07:27 -0600)
Some of the fsck and mkfs commands complete differently than the others,
and differently than the desired behavior.[1]  Standardize on completing
with $(lsblk -pnro name):

* fsck: Don't complete completes on all block devices and device links
  under /dev immediately (which is excessive and prone to search
  problems).
* mkfs, mkfs.bfs: Don't complete "/path/to/file" literally.  I assume
  this was copy/pasted from example code, since it does not appear to be
  a valid argument unless it is a valid path, which is rare.
* fsck.cramfs, mkfs, mkfs.bfs, mkfs.cramfs, mkswap: Don't complete on
  all filenames initially.  The desired behavior is to complete
  filenames only if there are no canonical matches.[1]

Note: A subsequent commit will add the desired fallback behavior.

[1]: https://github.com/karelzak/util-linux/issues/842#issuecomment-523450243

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
bash-completion/fsck
bash-completion/fsck.cramfs
bash-completion/mkfs
bash-completion/mkfs.bfs
bash-completion/mkfs.cramfs
bash-completion/mkswap

index e5b4f53b4de7a1703d5fa6eaa08e4d44c08ab992..301bb5d00ea1536dbeee88e99a0d3594c7472472 100644 (file)
@@ -32,8 +32,7 @@ _fsck_module()
                        return 0
                        ;;
        esac
-       COMPREPLY=( $(compgen -W "$(find -L /dev/ -path /dev/fd -prune \
-               -o -type b -print 2>/dev/null)" -- $cur) )
+       COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
        return 0
 }
 complete -F _fsck_module fsck
index d17d2fea7a1b11019b3e1032c8ac310453e9b278..c92a6bd466467b1ac224f162c7ba83055a58234d 100644 (file)
@@ -25,9 +25,7 @@ _fsck.cramfs_module()
                        return 0
                        ;;
        esac
-       local IFS=$'\n'
-       compopt -o filenames
-       COMPREPLY=( $(compgen -f -- $cur) )
+       COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
        return 0
 }
 complete -F _fsck.cramfs_module fsck.cramfs
index a27874714e6b34159be89a9bddcf8c1737f882f6..173f7e58b16d13e901c7f0f954f56f8eb0c30f0a 100644 (file)
@@ -21,7 +21,7 @@ _mkfs_module()
                        return 0
                        ;;
        esac
-       COMPREPLY=( $(compgen -W "$(lsblk -pnro name) /path/to/file" -- $cur) )
+       COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
        return 0
 }
 complete -F _mkfs_module mkfs
index 75458bb09fff01f96fb6f09cda8cb6dd69a3cc3b..1faeb446b1a0792ea83098ad45b9707033c428dd 100644 (file)
@@ -24,7 +24,7 @@ _mkfs.bfs_module()
                        return 0
                        ;;
        esac
-       COMPREPLY=( $(compgen -W "$(lsblk -pnro name) /path/to/file" -- $cur) )
+       COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
        return 0
 }
 complete -F _mkfs.bfs_module mkfs.bfs
index af74e1212a456a381c42d7cb5124852069790d63..23e1d66f8157227fcb06ee69f107b44d09340dfa 100644 (file)
@@ -36,9 +36,7 @@ _mkfs.cramfs_module()
                        return 0
                        ;;
        esac
-       local IFS=$'\n'
-       compopt -o filenames
-       COMPREPLY=( $(compgen -f -- $cur) )
+       COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
        return 0
 }
 complete -F _mkfs.cramfs_module mkfs.cramfs
index 6ccc2142154d4ead5573ecde522841f880181161..ad8b51e66b4e627e5716efcc18492378a64a414e 100644 (file)
@@ -32,9 +32,7 @@ _mkswap_module()
                        return 0
                        ;;
        esac
-       local IFS=$'\n'
-       compopt -o filenames
-       COMPREPLY=( $(compgen -f -- $cur) )
+       COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
        return 0
 }
 complete -F _mkswap_module mkswap