[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: turn off word splitting for vars but keep for read
From: |
Peggy Russell |
Subject: |
Re: RFC: turn off word splitting for vars but keep for read |
Date: |
Fri, 22 Nov 2013 23:52:22 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
> ...
> $ IFS=""
> $ f() { echo $1; }; x="a b c"; f $x
> a b c
>
> But, IFS influences `read`, which of course benefits from word
> splitting. In light of that conflict, I propose two possible
> solutions:
>
> 1: shopt -s unsplit_vars
>
> which will turn off word splitting for var expansion.
>
> or 2: new IFS2 var that will override IFS for `read` (i.e. `read` will
> use IFS2 when IFS is unset).
>
Could also do:
IFS=$'\n\t'
echo "Checking..."; echo -n "$IFS"|hexdump
The IFS on the read could be considered script documentation for
the contents of the current file. Similar to awk's FS.
while IFS=: read -re line; do : ; done < file
Interesting read here, but pertains to splitting and filenames:
http://www.dwheeler.com/essays/filenames-in-shell.html
But could perhaps provide a supportive argument, maybe, for your suggestion
option #1. http://mywiki.wooledge.org/Quotes is helpful.
Peggy Russell
- Re: RFC: turn off word splitting for vars but keep for read, (continued)
- Re: RFC: turn off word splitting for vars but keep for read, Pierre Gaston, 2013/11/22
- Re: RFC: turn off word splitting for vars but keep for read, Aleksey Midenkov, 2013/11/22
- Re: RFC: turn off word splitting for vars but keep for read, Eric Blake, 2013/11/22
- Re: RFC: turn off word splitting for vars but keep for read, Pierre Gaston, 2013/11/22
- Re: RFC: turn off word splitting for vars but keep for read, Aleksey Midenkov, 2013/11/22
- Re: RFC: turn off word splitting for vars but keep for read, Bob Proulx, 2013/11/24
- Re: RFC: turn off word splitting for vars but keep for read, Greg Wooledge, 2013/11/25
- Re: RFC: turn off word splitting for vars but keep for read, Bob Proulx, 2013/11/25
- Re: RFC: turn off word splitting for vars but keep for read, Eduardo A . Bustamante López, 2013/11/22
Re: RFC: turn off word splitting for vars but keep for read, Greg Wooledge, 2013/11/22
Re: RFC: turn off word splitting for vars but keep for read,
Peggy Russell <=