[PATCH v3] virt-copy, virt-tar: show help for -h
Shows manpage for virt-copy-in,out and virt-tar-in,out when user supplies -h as a parameter instead of listing unrelated commands with descriptions. Maros Zatko (1): virt-copy, virt-tar: show help for -h fish/virt-copy-in | 9 +++++++++ fish/virt-copy-out | 9 +++++++++ fish/virt-tar-in | 9 +++++++++ fish/virt-tar-out | 9 +++++++++ 4 files changed, 36 insertions(+) -- 1.9.3
--- fish/virt-copy-in | 9 +++++++++ fish/virt-copy-out | 9 +++++++++ fish/virt-tar-in | 9 +++++++++ fish/virt-tar-out | 9 +++++++++ 4 files changed, 36 insertions(+) diff --git a/fish/virt-copy-in b/fish/virt-copy-in index 76ff57f..850f382 100755 --- a/fish/virt-copy-in +++ b/fish/virt-copy-in @@ -16,4 +16,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +for arg in $@; do + case $arg in + "-h") + man $(basename $0) + exit + ;; + esac +done + exec guestfish --rw -i copy-in "$@" diff --git a/fish/virt-copy-out b/fish/virt-copy-out index 20475ef..953c594 100755 --- a/fish/virt-copy-out +++ b/fish/virt-copy-out @@ -16,4 +16,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +for arg in $@; do + case $arg in + "-h") + man $(basename $0) + exit + ;; + esac +done + exec guestfish --ro -i copy-out "$@" diff --git a/fish/virt-tar-in b/fish/virt-tar-in index 1501b38..6662858 100755 --- a/fish/virt-tar-in +++ b/fish/virt-tar-in @@ -16,4 +16,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +for arg in $@; do + case $arg in + "-h") + man $(basename $0) + exit + ;; + esac +done + exec guestfish --rw -i tar-in "$@" diff --git a/fish/virt-tar-out b/fish/virt-tar-out index 4d30de4..19a1ed6 100755 --- a/fish/virt-tar-out +++ b/fish/virt-tar-out @@ -16,4 +16,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +for arg in $@; do + case $arg in + "-h") + man $(basename $0) + exit + ;; + esac +done + exec guestfish --ro -i tar-out "$@" -- 1.9.3
On Fri, Feb 06, 2015 at 02:11:13PM +0100, Maros Zatko wrote:
--- fish/virt-copy-in | 9 +++++++++ fish/virt-copy-out | 9 +++++++++ fish/virt-tar-in | 9 +++++++++ fish/virt-tar-out | 9 +++++++++ 4 files changed, 36 insertions(+)
diff --git a/fish/virt-copy-in b/fish/virt-copy-in index 76ff57f..850f382 100755 --- a/fish/virt-copy-in +++ b/fish/virt-copy-in @@ -16,4 +16,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+for arg in $@; do + case $arg in + "-h")
This needs to be --help. I don't think anyone uses -h for help outside DOS programs.
+ man $(basename $0) + exit
There are a few problems here: (1) You lose the exit code from 'man'. If you write the following instead: exec man $(basename $0) then the script will exit with the same exit code as the man process. (2) Quoting, maybe. Likely this is better: exec man $(basename "$0") Anyway, I made these changes and pushed it. Thanks, Rich.
+ ;; + esac +done + exec guestfish --rw -i copy-in "$@"
diff --git a/fish/virt-copy-out b/fish/virt-copy-out index 20475ef..953c594 100755 --- a/fish/virt-copy-out +++ b/fish/virt-copy-out @@ -16,4 +16,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+for arg in $@; do + case $arg in + "-h") + man $(basename $0) + exit + ;; + esac +done + exec guestfish --ro -i copy-out "$@" diff --git a/fish/virt-tar-in b/fish/virt-tar-in index 1501b38..6662858 100755 --- a/fish/virt-tar-in +++ b/fish/virt-tar-in @@ -16,4 +16,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+for arg in $@; do + case $arg in + "-h") + man $(basename $0) + exit + ;; + esac +done + exec guestfish --rw -i tar-in "$@" diff --git a/fish/virt-tar-out b/fish/virt-tar-out index 4d30de4..19a1ed6 100755 --- a/fish/virt-tar-out +++ b/fish/virt-tar-out @@ -16,4 +16,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+for arg in $@; do + case $arg in + "-h") + man $(basename $0) + exit + ;; + esac +done + exec guestfish --ro -i tar-out "$@" -- 1.9.3
_______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
participants (2)
-
Maros Zatko -
Richard W.M. Jones