[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printf '%s\n' "$@" versus <<< redirection
From: |
Greg Wooledge |
Subject: |
Re: printf '%s\n' "$@" versus <<< redirection |
Date: |
Sun, 19 Feb 2023 09:02:49 -0500 |
On Sun, Feb 19, 2023 at 10:38:22AM +0000, Kerin Millar wrote:
> $ printf 'n\n' | { IFS='\n' read -r vl; declare -p vl; }
> declare -- vl=""
What the hell...?
unicorn:~$ printf 'n\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl=""
unicorn:~$ printf 'no\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl="no"
unicorn:~$ printf 'on\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl="o"
unicorn:~$ printf 'noon\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl="noon"
What is it doing there? And why?
Also:
unicorn:~$ bash-2.05b
unicorn:~$ printf 'n\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl="n"
unicorn:~$ printf 'no\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl="no"
unicorn:~$ printf 'on\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl="on"
unicorn:~$ printf 'noon\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl="noon"
THAT one behaves as I would expect. It looks like the behavior
changes between bash 3.0 and bash 3.1:
bash-3.0:
declare -- vl="n"
declare -- vl="no"
declare -- vl="on"
declare -- vl="noon"
bash-3.1:
declare -- vl=""
declare -- vl="no"
declare -- vl="o"
declare -- vl="noon"
This looks like a bug to me. Either it strips trailing n's, or it doesn't,
but in no case should it strip the trailing n only when the string is
less then 4 characters long!
unicorn:~$ printf 'non\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl="non"
unicorn:~$ printf 'bon\n' | { IFS='\n' read -r vl; declare -p vl; }
declare -- vl="bo"
Utter nonsense. Someone please explain this.
- Re: printf '%s\n' "$@" versus <<< redirection, (continued)
Re: printf '%s\n' "$@" versus <<< redirection, alex xmb ratchev, 2023/02/18
- Re: printf '%s\n' "$@" versus <<< redirection, Kerin Millar, 2023/02/18
- Re: printf '%s\n' "$@" versus <<< redirection, alex xmb ratchev, 2023/02/18
- Re: printf '%s\n' "$@" versus <<< redirection, Mike Jonkmans, 2023/02/18
- Re: printf '%s\n' "$@" versus <<< redirection, Kerin Millar, 2023/02/18
- Re: printf '%s\n' "$@" versus <<< redirection, goncholden, 2023/02/19
- Re: printf '%s\n' "$@" versus <<< redirection, Kerin Millar, 2023/02/19
- Re: printf '%s\n' "$@" versus <<< redirection,
Greg Wooledge <=
- Re: printf '%s\n' "$@" versus <<< redirection, Kerin Millar, 2023/02/19
- Re: printf '%s\n' "$@" versus <<< redirection, Greg Wooledge, 2023/02/19
- Re: printf '%s\n' "$@" versus <<< redirection, Kerin Millar, 2023/02/19
Re: printf '%s\n' "$@" versus <<< redirection, Greg Wooledge, 2023/02/19
Re: printf '%s\n' "$@" versus <<< redirection, goncholden, 2023/02/20
Re: printf '%s\n' "$@" versus <<< redirection, Greg Wooledge, 2023/02/20
Re: printf '%s\n' "$@" versus <<< redirection, goncholden, 2023/02/20
Re: printf '%s\n' "$@" versus <<< redirection, Chet Ramey, 2023/02/20
Re: printf '%s\n' "$@" versus <<< redirection, Mike Jonkmans, 2023/02/20
Re: printf '%s\n' "$@" versus <<< redirection, Greg Wooledge, 2023/02/20