Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=722c11256c8c954207daae297de409395f7ff8e0

commit 722c11256c8c954207daae297de409395f7ff8e0
Author: Michel Hermier <[email protected]>
Date:   Wed Nov 6 18:37:19 2013 +0100

makepkg: Add option to makepkg_env to spawn an interactive shell if no argument 
is given.

diff --git a/scripts/makepkg b/scripts/makepkg
index d13383c..b3abd45 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -386,21 +386,24 @@ _makepkg_commands[chroot]=makepkg_chroot
# TODO: Add chrootadd, chrootdel.

makepkg_env_usage() {
-       $ECHO "Usage: $0 [OPTION]... [-] [NAME=VALUE]... [--] [COMMAND 
[ARG]...]"
-       $ECHO "Run a command in a modified environment."
+       $ECHO "Usage: $0 env [OPTION]... [-] [NAME=VALUE]... [--] [COMMAND 
[ARG]...]"
+       $ECHO "Run a command in a modified environment or display the 
environment if no command is given."
$ECHO
$ECHO "Options for chroot_enter command:"
-       $ECHO "  -h, --help             This help."
-       $ECHO "  -u, --unset=NAME       Remove variable from environment."
+       $ECHO "  -i, --interactive  Instead of displaying the environment, run 
'${SHELL} -i' (default: '/bin/sh -i')."
+       $ECHO "  -h, --help         This help."
+       $ECHO "  -u, --unset=NAME   Remove variable from environment."
}

makepkg_env() {
( # Protect environment with a subshell
-       local _options_consumed
+       local _interactive=0 _options_consumed

while [ $# -gt 0 ]; do
_options_consumed=1
case "$1" in
+               -i|--interactive)
+                       _interactive=1;;
-h|--help)
makepkg_env_usage
return 0 ;;
@@ -447,9 +450,14 @@ makepkg_env() {
shift
done
if [ $# -eq 0 ]; then
-               set -- env
+               if [ $_interactive -eq 0 ]; then
+                       set -- env
+               else
+                       : ${SHELL='/bin/sh'}
+                       set -- "${SHELL}" -i
+               fi
fi
-       unset _options_consumed
+       unset _interactive _options_consumed

case "$1" in
'!')    ! "${@:2}" ;;
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to