Andre Noll [Fri, 16 May 2014 13:35:32 +0000 (15:35 +0200)]
gsu: User banner text also for gsu gui.
Currently the $gsu_banner_txt variable is used only for subcommand
utilities but not for dialog-based tools. There is no real reason for
this restriction, so this commit starts to use the variable also for
the various GUIs.
Andre Noll [Fri, 13 Dec 2013 09:57:42 +0000 (10:57 +0100)]
gsu_gui: Add check for dialog executable.
Currently, programs which use gsu_gui exit silently with no indication about
what went wrong if dialog is not installed. This patch makes it print an error
message in this case.
Andre Noll [Wed, 12 Oct 2011 08:26:38 +0000 (10:26 +0200)]
gsu_getopts: Rename local variable opt to _gsu_getopts_opt.
As pointed out by Sebastian Stark, calling the loop variable "opt"
in code which is supposed to be eval'd by the application may conflict
with another local variable of the same name defined in the function
which calls gsu_getopt().
This could lead to rather obscure bugs which are hard to detect.
The callers don't use this loop variable directly, so we are free
to call it whatever we want. Therefore this patch renames $opt to
something which is much less likely to cause a conflict.
Andre Noll [Thu, 29 Sep 2011 13:12:33 +0000 (15:12 +0200)]
gsu: Overhaul of the rexexp matching for help commands.
The old sed scripts were unreadable and broken on non-gnu systems
since they made use of some gnuisms of grep and sed like \+ in regular
expressions to match at least one character or sed's T command which
jumps to a label if no substitution has been made since the most
recent reading of an input line.
This patch switches to extended regular expressions and replaces all
broken sed scripts by portable ones, which are known to work at least
on FreeBSD and MacOS. The new scripts are commented verbosely so that
any subsequent changes do not require a full rewrite, hopefully.
Andre Noll [Fri, 23 Sep 2011 15:21:58 +0000 (17:21 +0200)]
gsu: Initial completion support.
This adds the framework for command completion of scripts which make
use of the gsu subcommand library. The idea is to implement as much
as possible as generic helpers within gsu in order to minimize code
duplication in the scripts which source the gsu library.
The new "complete" subcommand is automatically included in each
application, just like the help, man and prefs commands we already
have. This subommand is meant to be used as the completer which calls
the custom subcommand completers included in the application.
Two new public helper functions, gsu_complete_options() and
gsu_cword_is_option_parameter() are introduced in this commit.
The former function takes a usual getopt string and completes according
to all options in this string. The latter is useful for completers
which need to determine whether the current word is the parameter to
some option in order to find out how to complete the current word.
For example, the -s option of cmt's vmem command takes a mandatory
parameter which is a number. So the completer for this command must
complete differently depending on whether the previous word is "-s".
Andre Noll [Fri, 23 Sep 2011 12:03:38 +0000 (14:03 +0200)]
Split gsu.
This patch splits the gsu file into two files for config parsing and
subcommand handling respectively. Each part may be used independently
of the other.
Moreover, all scripts which use gsu now include the needed parts
directly rather than relying on the shell to have already sourced
the needed gsu files. This shortens bash startup time and makes gsu
easier to use for people whose login shell is not bash.
Andre Noll [Tue, 2 Aug 2011 13:12:48 +0000 (15:12 +0200)]
Allow hyphens in command names.
There is no reason to forbid subcommands with hyphens, and sometimes
it is just natural have such a command. For instance if the subcommand
wraps an existing command with a hyphen like "apt-get".
So change the regular expression for subcommands accordingly.
Andre Noll [Tue, 2 Aug 2011 13:09:21 +0000 (15:09 +0200)]
gsu: Avoid duplication of command regex.
The regular expression for fining the subcommands was duplicated
four times in gsu. Needless to say that this resulted in more than
one variant of the expression...
Avoid this duplication by introducing the global gsu_command_regex
variable. While at it, use a more clever sed command in
_gsu_available_commands() which allows to kill a grep command.
Andre Noll [Thu, 25 Mar 2010 14:23:25 +0000 (15:23 +0100)]
gsu: Fix com_prefs() for invalid preferences.
The prefs command would print only empty values for
all options that come after an invalid option.
Refuse to execute com_prefs() in this case is the most
simple fix.