bug-bash
[Top][All Lists]
Advanced

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

Re: tilde character not interpreted in variable set


From: Nick Chambers
Subject: Re: tilde character not interpreted in variable set
Date: Fri, 2 Mar 2018 15:09:36 +0000


On 3/2/18, 9:03 AM, "bug-bash on behalf of Koncz, Istvan (Extern)" 
<bug-bash-bounces+nchambers=lightspeedsystems.com@gnu.org on behalf of 
istvan.koncz@oediv.de> wrote:

    
    Configuration Information [Automatically generated, do not change]:
    Machine: x86_64
    OS: linux-gnu
    Compiler: gcc
    Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
    -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
    -DCONF_VENDOR='unknown'
    -DLOCALEDIR='/home/konczi.ext/apps/bin/share/locale' -DPACKAGE='bash'
    -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -g -O2 -Wno-
    parentheses -Wno-format-security
    uname output: Linux OED-EX-DIG-L 4.13.0-36-generic #40-Ubuntu SMP Fri
    Feb 16 20:07:48 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
    Machine Type: x86_64-unknown-linux-gnu
    
    Bash Version: 4.4
    Patch Level: 18
    Release Status: release
    
    Description:
    when i use ~/ for home folder it works in command line e.g. ls
    -la ~/.vimrc works, but when i add it to a variable e.g. foo="~/.vimrc"
    then ~/ will not be replaced to $HOME value like in command line, but i
    think it should be. ~ is a special character so must be escapped like
    \~ if i want the char, but without escape it should provide the home
    like in ls -la ~/ command. In my oppinion it is a bug.
    Current workaround is in shell script to use $HOME not ~/ but would be
    better if ~/ would be consistent and behave everywhere as same.

Are you sure this is a bug? Consider the following:

ubuntu:~ nchambers$ echo ~
/home/nchambers
ubuntu:~ nchambers$ echo "~"
~
ubuntu:~ nchambers$ tmp=~
ubuntu:~ nchambers$ echo "$tmp"
/home/nchambers
ubuntu:~ nchambers$ tmp="~"
ubuntu:~ nchambers$ echo "$tmp"
~
ubuntu:~ nchambers$

~ is not an actual path, but rather a symbolic value expanded by the shell to 
whatever value is in HOME. Wrapping it in quotes prevents this expansion.

    Repeat-By:
    foo="~/.vimrc"
    echo $foo
    ~/.vimrc
    ls -la $foo
    ls: cannot access '~/.vimrc': No such file or directory
    
    ls -la ~/.vimrc
    -rw-r--r-- 1 konczi.ext users 19 Jan  2 12:49 /home/konczi.ext/.vimrc
    
    Fix:
    i would replace ~/ or ~ with $HOME value when there is a
    variable definition. If \~ is used, no replacement is needed because of
    the escaping.
    
    
    
    --
    Mit freundlichen Grüßen/Kind regards
    
    Istvan Koncz
    
    
----------------------------------------------------------------------------------------------------------------------------
    
    Istvan Koncz
    OEDIV Digital Services (ODS)
    
    OEDIV Oetker Daten- und Informationsverarbeitung KG
    Bechterdisser Str. 10
    33719 Bielefeld, Germany
    
    phone:   +49 521
    fax:         +49 521 26050 445
    mailto:   istvan.koncz@oediv.de
    web:       www.oediv.de
    
----------------------------------------------------------------------------------------------------------------------------
    Gesellschaftssitz: Bielefeld
    Registergericht: Amtsgericht Bielefeld HRA 13532
    Der Umwelt zuliebe: E-Mails und Anhänge nur ausdrucken, wenn unbedingt 
nötig.
    Save paper - print e-mails and attachments only when absolutely necessary.
    
    _________________________________________________
    
    Dieses E-Mail kann Informationen enthalten, die vertraulich sind und/oder 
dem Berufsgeheimnis unterfallen.
    Diese Information ist nur für den Gebrauch durch die in diesem E-Mail 
benannte Person oder Rechtseinheit
    bestimmt. Jede(r) unautorisierte Durchsicht, Gebrauch, Verwendung, 
Offenlegung oder Verbreitung ist verboten.
    Falls Sie nicht der beabsichtigte Empfänger sind, bitten wir Sie, den 
Absender durch Antwort E-Mail zu
    benachrichtigen und das empfangene E-Mail dauerhaft zu löschen sowie alle 
Kopien hiervon zu vernichten.
    Vielen Dank.
    Da über das Internet versandte E-Mails während des Übermittlungsprozesses 
leicht verfälscht und/oder unter
    fremden Namen erstellt werden können, übernehmen wir keine Verantwortung 
für den Inhalt der E-Mail oder der
    Anhänge und folglich kann der Inhalt des E-Mails kein rechtlich bindendes 
Angebot und keine rechtlich
    bindende Annahme eines Angebots begründen sofern nicht ausdrücklich 
schriftlich anders vereinbart. Diese
    E-Mail dient ausschließlich dem Informationsaustausch. Es gelten unsere 
Allgemeinen Geschäftsbedingungen.
    Wir unternehmen alle Anstrengungen, um unser Netzwerk von Viren 
freizuhalten. Dennoch sollten Sie dieses
    E-Mail und seine Anhänge auf Viren überprüfen, da wir keine Verantwortung 
für Computerviren übernehmen,
    die durch dieses Mail unbeabsichtigt übermittelt werden könnten.
    
    This e-mail may contain information that is confidential and/or privileged. 
This information is intended only
    for the use of the individual or entity named in this e-mail. Any 
unauthorized review, use, disclosure or
    distribution is prohibited. If you are not the intended recipient, please 
immediately contact the sender by
    reply e-mail and permanently delete the original message and destroy all 
copies thereof. Thank you.
    We do not enter into binding agreements via e-mail absent express written 
consent. As any e-mail sent over the
    internet can be improperly altered electronically during the process of 
transmission or be sent under the name
    of a third person, we assume no responsibility for the content of the 
e-mail or any of its attachments and,
    consequently, the content of this e-mail shall not constitute a legally 
binding offer or acceptance of an
    offer, unless otherwise agreed in writing. This e-mail is only intended to 
exchange information. Our standard
    terms and conditions are applicable. We make every effort to keep our 
network free from viruses. However, you
    do need to scan this e-mail and any attachments to it for viruses as we can 
take no responsibility for any
    computer virus which might be transferred by way of this e-mail 
unintentionally.
    


reply via email to

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