[PATCH] 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 | 13 ++++++++++++- fish/virt-copy-out | 13 ++++++++++++- fish/virt-tar-in | 13 ++++++++++++- fish/virt-tar-out | 13 ++++++++++++- 4 files changed, 48 insertions(+), 4 deletions(-) -- 1.9.3
--- fish/virt-copy-in | 13 ++++++++++++- fish/virt-copy-out | 13 ++++++++++++- fish/virt-tar-in | 13 ++++++++++++- fish/virt-tar-out | 13 ++++++++++++- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/fish/virt-copy-in b/fish/virt-copy-in index 76ff57f..97a47da 100755 --- a/fish/virt-copy-in +++ b/fish/virt-copy-in @@ -16,4 +16,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -exec guestfish --rw -i copy-in "$@" +args=$@ +while [ ""x != "$1"x ] ; do + case $(echo $@ | awk '{print $1}') in + "-h") + man $(basename $0) + exit + ;; + esac + shift 1 +done + +exec guestfish --rw -i copy-in "$args" diff --git a/fish/virt-copy-out b/fish/virt-copy-out index 20475ef..70e470a 100755 --- a/fish/virt-copy-out +++ b/fish/virt-copy-out @@ -16,4 +16,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -exec guestfish --ro -i copy-out "$@" +args=$@ +while [ ""x != "$1"x ] ; do + case $(echo $@ | awk '{print $1}') in + "-h") + man $(basename $0) + exit + ;; + esac + shift 1 +done + +exec guestfish --ro -i copy-out "$args" diff --git a/fish/virt-tar-in b/fish/virt-tar-in index 1501b38..946c970 100755 --- a/fish/virt-tar-in +++ b/fish/virt-tar-in @@ -16,4 +16,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -exec guestfish --rw -i tar-in "$@" +args=$@ +while [ ""x != "$1"x ] ; do + case $(echo $@ | awk '{print $1}') in + "-h") + man $(basename $0) + exit + ;; + esac + shift 1 +done + +exec guestfish --rw -i tar-in "$args" diff --git a/fish/virt-tar-out b/fish/virt-tar-out index 4d30de4..7342d8a 100755 --- a/fish/virt-tar-out +++ b/fish/virt-tar-out @@ -16,4 +16,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -exec guestfish --ro -i tar-out "$@" +args=$@ +while [ ""x != "$1"x ] ; do + case $(echo $@ | awk '{print $1}') in + "-h") + man $(basename $0) + exit + ;; + esac + shift 1 +done + +exec guestfish --ro -i tar-out "$args" -- 1.9.3
On Fri, Jan 23, 2015 at 02:59:47PM +0100, Maros Zatko wrote:
-exec guestfish --rw -i copy-in "$@" +args=$@ +while [ ""x != "$1"x ] ; do + case $(echo $@ | awk '{print $1}') in + "-h") + man $(basename $0) + exit + ;; + esac + shift 1 +done
Bit confused about what this shell fragment does. It doesn't look as if it would be safe given command line arguments containing spaces either. How about using getopt? Rich. -- 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
On Fri, Jan 23, 2015 at 02:59:47PM +0100, Maros Zatko wrote:
-exec guestfish --rw -i copy-in "$@" +args=$@ +while [ ""x != "$1"x ] ; do + case $(echo $@ | awk '{print $1}') in + "-h") + man $(basename $0) + exit + ;; + esac + shift 1 +done Bit confused about what this shell fragment does. It doesn't look as if it would be safe given command line arguments containing spaces either.
How about using getopt? I did it with getopt first, it did not take -h into account unless it was
On 01/23/2015 03:21 PM, Richard W.M. Jones wrote: the first argument and giving confusing answer. Offending string could be "this is -h the one". Is it (preferably easily) solvable? - maros
Rich.
participants (2)
-
Maros Zatko -
Richard W.M. Jones