commit ffd2dcd06cfd7449e926881fba0ec7596130adb6
parent 9ed112f0a402bec465490553d94729d7dc3179ed
Author: Spenser Truex <web@spensertruex.com>
Date:   Sun,  5 Apr 2020 21:04:11 -0700
Make profileid optional for hardened update
ehardened can be used to update a hardened kernel profile's gcc profile even if
it is the same kernel profile.
So if I want to update from gcc 9.2 to 9.3 with ehardened, I'll call `ehardened
<no args>`.
Signed-off-by: Christoph Lohmann <20h@r-36.net>
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/bin/ehardened b/bin/ehardened
@@ -1,8 +1,10 @@
 #!/bin/sh
 
-if [ $# -lt 1 ];
+[ $# -gt 1 ] && echo "Wrong number of arguments: Expected 1 or 0" && exit 1
+
+if [ $# -lt 1 ] && [ -z "$(eselect profile show | grep hardened)" ];
 then
-	printf "usage:\n    %s profileid\n\n" "$(basename "$0")" >&2
+	printf "usage:\n    %s [profileid]\n\n" "$(basename "$0")" >&2
 	printf "The following profile ids are available:...\n" >&2
 	eselect profile list
 	exit 1
@@ -19,7 +21,7 @@ pnum="$1"
 #	exit 1
 #fi
 
-eselect profile set $pnum
+[ $# -eq 1 ] && eselect profile set $pnum
 
 emerge -1 gcc
 gcc-config -l