aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2020-01-17 14:36:29 -0800
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>2020-01-18 00:24:06 +0100
commit8df14c229c02a3b9329afc6e3ebf4f8aec5b59ed (patch)
tree1575b44a4ec6002d6eae3015c61dd8d6f3559b98 /package/base-files
parent26105974e7f9758cd4bc443ce0322983f818acd5 (diff)
downloadupstream-8df14c229c02a3b9329afc6e3ebf4f8aec5b59ed.tar.gz
upstream-8df14c229c02a3b9329afc6e3ebf4f8aec5b59ed.tar.bz2
upstream-8df14c229c02a3b9329afc6e3ebf4f8aec5b59ed.zip
base-files/functions.sh: use grep -q instead of []
It's cleaner and faster as it does not need to do extra work. Also removed $() to avoid executing the output. The shell can handle it. https://github.com/koalaman/shellcheck/wiki/SC2143 Signed-off-by: Rosen Penev <rosenp@gmail.com> [correct || to && for one conversion] Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'package/base-files')
-rwxr-xr-xpackage/base-files/files/lib/functions.sh8
1 files changed, 4 insertions, 4 deletions
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 8e189e4f4d..d2edef1a34 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -326,7 +326,7 @@ group_add_next() {
fi
gids=$(cut -d: -f3 ${IPKG_INSTROOT}/etc/group)
gid=65536
- while [ -n "$(echo "$gids" | grep "^$gid$")" ] ; do
+ while echo "$gids" | grep -q "^$gid$"; do
gid=$((gid + 1))
done
group_add $1 $gid
@@ -336,8 +336,8 @@ group_add_next() {
group_add_user() {
local grp delim=","
grp=$(grep -s "^${1}:" ${IPKG_INSTROOT}/etc/group)
- [ -z "$(echo $grp | cut -d: -f4 | grep $2)" ] || return
- [ -n "$(echo $grp | grep ":$")" ] && delim=""
+ echo "$grp" | cut -d: -f4 | grep -q $2 && return
+ echo "$grp" | grep -q ":$" && delim=""
[ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd
sed -i "s/$grp/$grp$delim$2/g" ${IPKG_INSTROOT}/etc/group
[ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd
@@ -354,7 +354,7 @@ user_add() {
[ -z "$uid" ] && {
uids=$(cut -d: -f3 ${IPKG_INSTROOT}/etc/passwd)
uid=65536
- while [ -n "$(echo "$uids" | grep "^$uid$")" ] ; do
+ while echo "$uids" | grep -q "^$uid$"; do
uid=$((uid + 1))
done
}