tag 76768 notabug
close 76768
stop

On 3/6/25 03:46, G.K. wrote:
#1
echo -e "1\n2\n3\n4"'' | tac | cut -zf-4

First of all, let's simplify the test case: change non-portable 'echo -e' to 
printf,
and avoiding tac(1).

  $ echo -e '1\n2\n3\n4' | tac | od -tx1z
  0000000 34 0a 33 0a 32 0a 31 0a                          >4.3.2.1.<

  $ printf '4\n3\n2\n1\n' | od -tx1z
  0000000 34 0a 33 0a 32 0a 31 0a                          >4.3.2.1.<

Now, the test case is:

  $ printf '4\n3\n2\n1\n' | cut -zf-4

WILL NOT DISPLAYED ONE LINE

Sorry, I do not understand what the expected outcome is.

While -z tells cut(1) to use zero-terminated input, still the
delimiter between fields is a tab.
Since there is no '\0' in the input, all of the input is row one.
As the row does not contain any tab, there is only one field,
written as string: '4\n3\n2\n1\n'.

Therefore -f-4 meaning "print all fields up to field 4" just does that,
although there only field 1, but no fields 2 to 4.

The following input with a tab as delimiter between the fields illustrates
that only "up to 4 fields" are output:

  $ printf 'a\tb\tc\td\te' | cut -zf-4
  a     b       c       d

As such, I don't see a bug in cut(1), but rather a confusion about how
the field delimiter works.

THIS IS TEST TWO FROM cut
#2
second picture in attachment

Screenshots are not a good way to show reproducers, because one would have
to type manually to reproduce.  That is prone to errors.
Most readers might not even attempt to open attachments.

the sign asterisk in a file  for the "cut" byte options start print the 
actually directory with filenames

c14 source for start "cut" and Dir /awk

The problem is in the line
  echo ${svn[$i]}
where the unquoted ${svn[$i]} resolves to an *, and therefore the shell 
performs the
glob expansion before passing the result of that - i.e. all file names in the 
current
directory - to the echo builtin.

Therefore this is a matter of proper quoting, and not a problem in cut(1).

THIS TEST printing THE ERR from
COMMAND printf with  "$@"

in the second picture is displayed
whats wrong
you see it the difference all printf calls with "$@"



#3
#$ . hashmark 1 2

fname(){
          declare local IFS='#'
          echo "var IFS local #1 $1 $2 , \$# $# , \$* $* , \$@ $@"
          }

fname $1 $2
echo
printf "%s%s%s%s%s%s%s%s\n"'var IFS global #2 '"$1 $2"' , $# '"$#"' , $* '"$*"' , $@ 
'"$@"
echo
printf "\n%s%s"\$@ $@
echo
printf '$@'"%s"$@
echo
printf "%s%s"'$@ '$@
echo
printf "%s" $@
echo
printf "%s"$@
echo
printf "%s %s" "\$@" " $@ "
echo

Sorry, also here I'm quite lost what you wan to achieve, but most probably this
is also a problem of missing or wrong quotes.  Just start with this to list
all parameters correctly which have been passed to the shell script:

  printf "var='%s'\n" "$@"

Again, this is rather a shell topic and no problem with the GNU coreutils.
Hence, I'm closing this as "notabug" in our bug tracker.

Have a nice day,
Berny




Reply via email to