emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#23227: closed (Inconsistent behavior for --file=~/


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#23227: closed (Inconsistent behavior for --file=~/some-file)
Date: Tue, 05 Apr 2016 22:04:02 +0000

Your message dated Tue, 5 Apr 2016 16:03:48 -0600
with message-id <address@hidden>
and subject line Re: bug#23227: Inconsistent behavior for --file=~/some-file
has caused the debbugs.gnu.org bug report #23227,
regarding Inconsistent behavior for --file=~/some-file
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
23227: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23227
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: Inconsistent behavior for --file=~/some-file Date: Tue, 5 Apr 2016 23:55:41 +0200
Hi,

grep fails to parse the tilde (~) to represent $HOME, when it is used to
give a file's path to --file=, but it works with --file

% echo "a" > ~/tmp-pattern
% echo "hola" | LANG=C grep --file=/home/santiago/tmp-pattern
hola
% echo "hola" | LANG=C grep --file /home/santiago/tmp-pattern
hola
% echo "hola" | LANG=C grep --file ~/tmp-pattern
hola
% echo "hola" | LANG=C grep --file=${HOME}/tmp-pattern 
hola
% echo "hola" | LANG=C grep --file=~/tmp-pattern
grep: ~/tmp-pattern: No such file or directory

This was filed in debian:
https://bugs.debian.org/504804

Cheers,

Santiago



--- End Message ---
--- Begin Message --- Subject: Re: bug#23227: Inconsistent behavior for --file=~/some-file Date: Tue, 5 Apr 2016 16:03:48 -0600 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1
tag 23227 notabug
thanks

On 04/05/2016 03:55 PM, Santiago Ruano Rincón wrote:
> Hi,
> 
> grep fails to parse the tilde (~) to represent $HOME, when it is used to
> give a file's path to --file=, but it works with --file

That's not grep's fault, but the shell's.


> % echo "hola" | LANG=C grep --file ~/tmp-pattern
> hola
> % echo "hola" | LANG=C grep --file=${HOME}/tmp-pattern 
> hola

Try this to see that it is the shell:

$ echo testing --file ~/tmp-pattern
testing --file /home/eblake/tmp-pattern
$ echo testing --file=~/tmp-pattern
testing --file=~/tmp-pattern
$ echo testing --file=$HOME/tmp-pattern
testing --file=/home/eblake/tmp-pattern

Tilde expansion in the shell is defined by POSIX to only happen if ~
occurs as the first character of a word (or, in special cases such as
"export foo=~/bar" where a shell builtin is consuming its operands in
assignment context - but this is not one of those special cases).  IN
other words, for ALL other uses where you are passing '--option=value',
tilde expansion does NOT happen in 'value'; and you are correct that
using '--option value' as two separate arguments (for all long options
where the argument is not optional) is the easiest way to get ~ to the
front of the word and thus have tilde expansion again.

Since this behavior is baked into your shell, there's nothing grep can
do about it, so I'm closing this as not a bug.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---

reply via email to

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