Don't always disable the GUI when CLI arguments are provided

Some CLI switches (-d, -f and -v) make sense even when
starting the GUI version of sbopkg.
Allow the usage of these flags also when starting the dialog
version of sbopkg.
Thanks to Patzy for raising the issue on #sbopkg and to
Chess Griffin for pointing out a weakness of the first version
of the patch.

Signed-off-by: Mauro Giachero <mauro.giachero@gmail.com>
This commit is contained in:
mauro.giachero 2009-02-16 16:57:14 +00:00
parent 7c04aeab39
commit c7a8c23b7e

View File

@ -2758,27 +2758,17 @@ main_menu () {
# END OF FUNCTIONS. What comes below is the actual start of the # END OF FUNCTIONS. What comes below is the actual start of the
# script when it is first run. # script when it is first run.
# If there are no command line options then we will use the dialog
# version of sbopkg.
if [ $# -eq 0 ]; then
DIAG=1 DIAG=1
config_check
directory_checks
pid_check
main_menu
cleanup
exit 0
fi
# This is the command line options and help. # This is the command line options and help.
while getopts ":b:cd:f:hi:lopq:rs:uv:" OPT; do while getopts ":b:cd:f:hi:lopq:rs:uv:" OPT; do
case $OPT in case $OPT in
b ) BFLAG=1 b ) BFLAG=1
BUILDPKGS=1 BUILDPKGS=1
BUILD="$OPTARG" BUILD="$OPTARG"
unset DIAG
;; ;;
c ) CHK_UPDATES=1 c ) CHK_UPDATES=1
unset DIAG
;; ;;
d ) LOCALREPO="$OPTARG" d ) LOCALREPO="$OPTARG"
;; ;;
@ -2788,20 +2778,28 @@ while getopts ":b:cd:f:hi:lopq:rs:uv:" OPT; do
BUILDPKGS=1 BUILDPKGS=1
INSTALLPKGS=1 INSTALLPKGS=1
BUILD="$OPTARG" BUILD="$OPTARG"
unset DIAG
;; ;;
l ) CHANGELOG=1 l ) CHANGELOG=1
unset DIAG
;; ;;
o ) OBSOLETESRC=1 o ) OBSOLETESRC=1
unset DIAG
;; ;;
p ) GETPKGS=1 p ) GETPKGS=1
unset DIAG
;; ;;
q ) GENSEARCH="$OPTARG" q ) GENSEARCH="$OPTARG"
unset DIAG
;; ;;
r ) RSYNC=1 r ) RSYNC=1
unset DIAG
;; ;;
s ) SEARCH="$OPTARG" s ) SEARCH="$OPTARG"
unset DIAG
;; ;;
u ) UPDATE=1 u ) UPDATE=1
unset DIAG
;; ;;
v ) VERSION=1 v ) VERSION=1
CUSTOMVER="$OPTARG" CUSTOMVER="$OPTARG"
@ -2836,11 +2834,15 @@ done
# End of option parsing. # End of option parsing.
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [[ $# -gt 0 ]]; then
echo "Error: unknown token \"$@\"" >&2
exit 0
fi
if [[ "$BFLAG" = 1 && "$BUILD" = "i" || "$IFLAG" = 1 && \ if [[ "$BFLAG" = 1 && "$BUILD" = "i" || "$IFLAG" = 1 && \
"$BUILD" = "b" ]]; then "$BUILD" = "b" ]]; then
echo "Error: The -b and -i options cannot be used together." echo "Error: The -b and -i options cannot be used together." >&2
echo "Please use one or the other. Exiting." echo "Please use one or the other. Exiting." >&2
exit 0 exit 0
fi fi
@ -2858,6 +2860,10 @@ directory_checks
# Check for another instance # Check for another instance
pid_check pid_check
if [[ "$DIAG" ]]; then
main_menu
cleanup
else
if [ -n "$BUILD" ]; then if [ -n "$BUILD" ]; then
if has_root; then if has_root; then
for PKGBUILD in $BUILD; do for PKGBUILD in $BUILD; do
@ -2866,7 +2872,7 @@ if [ -n "$BUILD" ]; then
process_queue process_queue
else else
crunch_fmt "You must run this script as the root user in order \ crunch_fmt "You must run this script as the root user in order \
to build packages." to build packages." >&2
cleanup cleanup
exit 0 exit 0
fi fi
@ -2889,7 +2895,8 @@ if [ -n "$GETPKGS" ]; then
fi fi
if [ -n "$RSYNC" ]; then if [ -n "$RSYNC" ]; then
echo "Rsyncing with Slackbuilds.org repository into $LOCALREPO/$SLACKVER." echo "Rsyncing with Slackbuilds.org repository into \
$LOCALREPO/$SLACKVER."
rsync_repo rsync_repo
echo "Finished rsync." echo "Finished rsync."
fi fi
@ -2919,4 +2926,6 @@ fi
cleanup cleanup
echo echo
echo "All done." echo "All done."
fi
exit 0 exit 0