diff options
author | Rosen Penev <rosenp@gmail.com> | 2022-08-20 13:50:40 -0700 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2023-02-03 11:34:20 +0100 |
commit | 7be11ee35ec5b95d9629ce316fbf1a91439b2f02 (patch) | |
tree | 3fd686231f6e6b02717b5d7f8bae9cea848354b1 /target/linux/mvebu | |
parent | 2a691fc7f2bac365d147beb593be4331f11c5dca (diff) | |
download | upstream-7be11ee35ec5b95d9629ce316fbf1a91439b2f02.tar.gz upstream-7be11ee35ec5b95d9629ce316fbf1a91439b2f02.tar.bz2 upstream-7be11ee35ec5b95d9629ce316fbf1a91439b2f02.zip |
mvebu/uDPU: simplify grep usage
Instead of using the shell's evaluation, use grep's -q parameter.
Found with shellcheck's SC2143.
Also replaced a head call with grep's -m.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'target/linux/mvebu')
-rw-r--r-- | target/linux/mvebu/cortexa53/base-files/lib/upgrade/uDPU.sh | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/target/linux/mvebu/cortexa53/base-files/lib/upgrade/uDPU.sh b/target/linux/mvebu/cortexa53/base-files/lib/upgrade/uDPU.sh index 0bb1dd12cc..1d65a5437b 100644 --- a/target/linux/mvebu/cortexa53/base-files/lib/upgrade/uDPU.sh +++ b/target/linux/mvebu/cortexa53/base-files/lib/upgrade/uDPU.sh @@ -18,10 +18,10 @@ udpu_check_emmc() { } udpu_part_prep() { - if [ "$(grep $1 /proc/mounts)" ]; then - mounted_part="$(grep $1 /proc/mounts | awk '{print $2}' | head -1)" + if grep -q "$1" /proc/mounts; then + mounted_part="$(grep -m 1 $1 /proc/mounts | awk '{print $2}')" umount $mounted_part - [ "$(grep -wo $mounted_part /proc/mounts)" ] && umount -l $mounted_part + grep -woq "$mounted_part" /proc/mounts && umount -l "$mounted_part" fi } @@ -52,7 +52,7 @@ udpu_do_part_check() { } udpu_do_misc_prep() { - if [ ! "$(grep -wo /misc /proc/mounts)" ]; then + if ! grep -woq /misc /proc/mounts; then mkdir -p /misc mount ${emmc_dev}p4 /misc @@ -97,13 +97,13 @@ udpu_do_initial_setup() { udpu_do_regular_upgrade() { # Clean /boot partition - mfks.ext4 is not available in chroot - [ "$(grep -wo /boot /proc/mounts)" ] && umount /boot + grep -woq /boot /proc/mounts && umount /boot mkdir -p /tmp/boot mount ${emmc_dev}p1 /tmp/boot rm -rf /tmp/boot/* # Clean /root partition - mkfs.f2fs is not available in chroot - [ "$(grep -wo /dev/root /proc/mounts)" ] && umount / + grep -woq /dev/root /proc/mounts && umount / mkdir -p /tmp/rootpart mount ${emmc_dev}p3 /tmp/rootpart rm -rf /tmp/rootpart/* @@ -139,7 +139,7 @@ platform_do_upgrade_uDPU() { for part in ${tmp_parts}; do umount $part # Force umount is necessary - [ "$(grep "${part}" /proc/mounts)" ] && umount -l $part + grep -q "${part}" /proc/mounts && umount -l "$part" done # Sysupgrade complains about /tmp and /dev, so we can detach them here |