Skip to content

expr substr "$list" $len2 1 != " " different behavior with the GNU implementation #8063

@sylvestre

Description

@sylvestre

reported here: https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2112445

#!/bin/sh
list='alpha avr hppa m68k loongarch64 (loong64) microblaze microblazeel or1k rx sh4 sh4eb tricore xtensa xtensaeb'; \
echo $list; \
len2=$((${#list}/2)); echo len2 = $len2; \
len2=$((${#list}/2)); \
if [ $len2 -gt 36 ]; then \
  while expr substr "$list" $len2 1 != " " >/dev/null; do \
    len2=$(($len2+1)); \
    echo $len2; \
  done; \
  list="$(expr substr "$list" 1 $(($len2-1)))\${Newline} $(expr substr "$list" $(($len2+1)) $len2)"; \
fi;

currently displays:

alpha avr hppa m68k loongarch64 (loong64) microblaze microblazeel or1k rx sh4 sh4eb tricore xtensa xtensaeb
len2 = 53
54
55
56
57
[...]

It should display

alpha avr hppa m68k loongarch64 (loong64) microblaze microblazeel or1k rx sh4 sh4eb tricore xtensa xtensaeb
len2 = 53

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions