diff options
| author | Daniel Golle | 2023-08-31 23:56:35 +0000 |
|---|---|---|
| committer | Daniel Golle | 2023-08-31 23:56:35 +0000 |
| commit | 1a07f1dff32b3af49e39533e33e8964b59535662 (patch) | |
| tree | fbdb639e2bb3e81a7969480ae197e96bedf514d7 | |
| parent | f429bd94f99e55548bf4fa8156c165017ce3c41c (diff) | |
| download | netifd-1a07f1dff32b3af49e39533e33e8964b59535662.tar.gz | |
make_ethtool_modes_h.sh: apply anti-bashism
Use 'printf' instead of 'echo -e' and use 'sed' instead of 'cut' to be
compatible with shells other than bash and not require cut.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
| -rwxr-xr-x | make_ethtool_modes_h.sh | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/make_ethtool_modes_h.sh b/make_ethtool_modes_h.sh index ec69130..7f5ac7b 100755 --- a/make_ethtool_modes_h.sh +++ b/make_ethtool_modes_h.sh @@ -38,30 +38,29 @@ EOF echo "#include <linux/ethtool.h>" | "$CC" -E - | \ grep "ETHTOOL_LINK_MODE_[0-9]*base[A-Za-z0-9]*_...._BIT.*" | \ sed -r 's/.*ETHTOOL_LINK_MODE_([0-9]*)base([A-Za-z0-9]*)_(....)_BIT.*/\1 \2 \3/' | \ - sort -u | LC_ALL=C sort -r -g | ( gothalf=0 ; while read speed mode duplex; do + sort -u | LC_ALL=C sort -r -g | ( gothalf=0 ; while read -r speed mode duplex; do if [ "$duplex" = "Half" ]; then if [ "$gothalf" = "1" ]; then - echo -e "$speed \tETHTOOL_MODE_HALF($p_speed, $p_mode)," + printf "%s" "$speed \tETHTOOL_MODE_HALF($p_speed, $p_mode),\n" fi gothalf=1 elif [ "$duplex" = "Full" ]; then if [ "$gothalf" = "1" ]; then if [ "$p_speed" = "$speed" ] && [ "$p_mode" = "$mode" ]; then - echo -e "$speed \tETHTOOL_MODE_BOTH($speed, $mode)," + printf "%d \t%s\n" "$speed" "ETHTOOL_MODE_BOTH($speed, $mode)," else - echo -e "$p_speed \tETHTOOL_MODE_HALF($p_speed, $p_mode)," - echo -e "$speed \tETHTOOL_MODE_FULL($speed, $mode)," + printf "%d \t%s\n" "$p_speed" "ETHTOOL_MODE_HALF($p_speed, $p_mode)," + printf "%d \t%s\n" "$speed" "ETHTOOL_MODE_FULL($speed, $mode)," fi gothalf=0 else - echo -e "$speed \tETHTOOL_MODE_FULL($speed, $mode)," + printf "%d \t%s\n" "$speed" "ETHTOOL_MODE_FULL($speed, $mode)," fi else continue fi p_speed="$speed" p_mode="$mode" - p_duplex="$duplex" - done ; [ "$gothalf" = "1" ] && echo -e "$p_speed \tETHTOOL_MODE_HALF($p_speed, $p_mode)," ) | \ - LC_ALL=C sort -g | cut -d' ' -f2- + done ; [ "$gothalf" = "1" ] && printf "%d \t%s\n" "$p_speed" "ETHTOOL_MODE_HALF($p_speed, $p_mode)," ) | \ + LC_ALL=C sort -g | sed -r 's/[0-9]* (.*)/\1/' echo "};" |