help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: case $var in $list) issue


From: Zachary Santer
Subject: Re: case $var in $list) issue
Date: Fri, 1 Nov 2024 18:44:50 -0400

On Fri, Nov 1, 2024 at 3:56 PM Greg Wooledge <greg@wooledge.org> wrote:
>
> echo $x, however, will never be acceptable.

$ var='::eat:drink:be merry::'

$ ( IFS=':'; printf '%%%s\n' ${var} )
%
%
%eat
%drink
%be merry
%

$ var=':eat:drink:be merry:'

$ ( IFS=':'; printf '%%%s\n' ${var} )
%
%eat
%drink
%be merry

$ var='eat:drink:be merry'

$ ( IFS=':'; printf '%%%s\n' ${var} )
%eat
%drink
%be merry

Non-whitespace IFS characters get treated differently, because how
else are you going to specify an empty string? But there's an empty
string before the first colon, but not after the last?

doc/man.1:
> The shell treats each character of IFS as a delimiter, and splits the
> results of the other expansions into words using these characters
> as field terminators.

The Internal Field Separator is a field terminator.

The explanation of the IFS variable in the "Shell Variables" section
of doc/bash.1 told me to look above for the "EXPANSION" section, but
that section was below.

Current devel branch commit, fffa5d0e7c.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]