[OpenWrt-Devel] [PATCH] mvebu: Replace backticks by $(...)
Jeff Kletsky
lede at allycomm.com
Wed Jul 24 15:18:53 EDT 2019
On 7/24/19 11:05 AM, Rosen Penev wrote:
> On Wed, Jul 24, 2019 at 10:48 AM Adrian Schmutzler
> <mail at adrianschmutzler.de> wrote:
>> Hi,
>>
>>> -----Original Message-----
>>> From: Rosen Penev [mailto:rosenp at gmail.com]
>>> Sent: Mittwoch, 24. Juli 2019 18:54
>>> To: Adrian Schmutzler <freifunk at adrianschmutzler.de>
>>> Cc: OpenWrt Development List <openwrt-devel at lists.openwrt.org>
>>> Subject: Re: [OpenWrt-Devel] [PATCH] mvebu: Replace backticks by $(...)
>>>
>>> On Wed, Jul 24, 2019 at 6:34 AM Adrian Schmutzler
>>> <freifunk at adrianschmutzler.de> wrote:
>>>> Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
>>>> ---
>>>> target/linux/mvebu/base-files/lib/upgrade/linksys.sh | 2 +-
>>>> target/linux/mvebu/base-files/sbin/fan_ctrl.sh | 6 +++---
>>>> 2 files changed, 4 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/target/linux/mvebu/base-files/lib/upgrade/linksys.sh
>>> b/target/linux/mvebu/base-files/lib/upgrade/linksys.sh
>>>> index 3f45d6cac5..ddf24836bc 100644
>>>> --- a/target/linux/mvebu/base-files/lib/upgrade/linksys.sh
>>>> +++ b/target/linux/mvebu/base-files/lib/upgrade/linksys.sh
>>>> @@ -6,7 +6,7 @@ linksys_get_target_firmware() {
>>>>
>>>> local cur_boot_part mtd_ubi0
>>>>
>>>> - cur_boot_part=`/usr/sbin/fw_printenv -n boot_part`
>>>> + cur_boot_part=$(/usr/sbin/fw_printenv -n boot_part)
>>>> if [ -z "${cur_boot_part}" ] ; then
>>>> mtd_ubi0=$(cat /sys/devices/virtual/ubi/ubi0/mtd_num)
>>>> case $(egrep ^mtd${mtd_ubi0}: /proc/mtd | cut -d '"' -f 2) in
>>> egrep is deprecated as well. I'm assuming you're running these through
>>> shellcheck.
>> I indeed got this hint from shellcheck, suggesting "grep -E" as replacement.
>> However, I'm not familiar with the old egrep.
>> So, I was not sure whether I really can replace it without side-effects, and since I cannot test on this target, I decided against changing that.
>>
>> If you tell me it's okay, I can include it in a v2.
> egrep is equivalent to grep -E. I have never seen any fallout from
> changing this.
[...]
The one place that I know it is critical to use `grep -E` over `egrep`
is during stage2 of sysupgrade, when `grep` is typically available and
`egrep` is often not.
switch_to_ramfs() {
for binary in \
/bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \
pivot_root mount_root reboot sync kill sleep \
md5sum hexdump cat zcat bzcat dd tar \
ls basename find cp mv rm mkdir rmdir mknod touch chmod \
'[' printf wc grep awk sed cut \
mtd partx losetup mkfs.ext4 \
ubiupdatevol ubiattach ubiblock ubiformat \
ubidetach ubirsvol ubirmvol ubimkvol \
snapshot snapshot_tool \
$RAMFS_COPY_BIN
[...]
As I've had my hands in `linksys.sh` recently (commit b3770eaca3), I can
say that the primary reason I didn't change it in that file then was to
keep the large number of changes somewhat more understandable.
Jeff
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list