[arch-projects] [mkinitcpio][PATCH] Add -V/--version option to display version information

Eric Bélanger snowmaniscool at gmail.com
Wed Oct 24 15:25:52 EDT 2012


Signed-off-by: Eric Bélanger <snowmaniscool at gmail.com>
---
 mkinitcpio | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/mkinitcpio b/mkinitcpio
index 8e5f9a8..27902f1 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -52,12 +52,19 @@ usage: ${0##*/} [options]
    -S, --skiphooks <hooks>      Skip specified hooks, comma-separated, during build
    -s, --save                   Save build directory. (default: no)
    -t, --builddir <dir>         Use DIR as the temporary build directory
+   -V, --version                Display version information and exit
    -v, --verbose                Verbose output (default: no)
    -z, --compress <program>     Use an alternate compressor on the image
 
 EOF
 }
 
+version() {
+    cat <<EOF
+mkinitcpio $version
+EOF
+}
+
 cleanup() {
     local err=${1:-$?}
 
@@ -243,10 +250,10 @@ install_modules() {
 trap 'cleanup 130' INT
 trap 'cleanup 143' TERM
 
-_opt_short='A:c:g:H:hk:nLMp:r:S:st:vz:'
+_opt_short='A:c:g:H:hk:nLMp:r:S:st:Vvz:'
 _opt_long=('add:' 'addhooks:' 'config:' 'generate:' 'hookhelp:' 'help'
           'kernel:' 'listhooks' 'automods' 'moduleroot:' 'nocolor'
-          'preset:' 'skiphooks:' 'save' 'builddir:' 'verbose' 'compress:')
+          'preset:' 'skiphooks:' 'save' 'builddir:' 'version' 'verbose' 'compress:')
 
 parseopts "$_opt_short" "${_opt_long[@]}" -- "$@" || exit 1
 set -- "${OPTRET[@]}"
@@ -277,6 +284,9 @@ while :; do
         -h|--help)
             usage
             cleanup 0 ;;
+        -V|--version)
+            version
+            cleanup 0 ;;
         -p|--preset)
             shift
             _optpreset=$1 ;;
-- 
1.8.0



More information about the arch-projects mailing list