All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnout Vandecappelle <arnout@mind.be>
To: Krzysztof Kanas <kkanas@fastmail.com>, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] package/environment-setup/environment-setup: add zsh
Date: Wed, 1 Sep 2021 16:59:17 +0200	[thread overview]
Message-ID: <81d1492a-d3ce-fc45-4227-4b05c0aeb4a0@mind.be> (raw)
In-Reply-To: <61d12e5e-db00-fc4f-4135-72d4aa926a68@fastmail.com>



On 01/09/2021 16:48, Krzysztof Kanas wrote:
> 
> 
> On 01/09/2021 15:26, Arnout Vandecappelle wrote:
>>
>>
>> On 30/08/2021 22:13, Krzysztof Kanas wrote:
>>> environment-setup used BASH_SOURCE which is bash specific and empty
>>> variable for zsh (and other shell's).
>>> Use $0 which should be work across multiple shells(tcsh, dash, zsh)
>>> It won't work if other script is sourcing environment-setup.
>>
>>   The environment-setup is supposed to be source'd, so how is this ever going to
>> work?
> This script will work when sourced interactively from bash shell due the test
> for ${BASH_SOURCE} so this behavior is not changed.
> 
> What I meant by this paragraph was how different shell's set $0 augment whether
> script is sourced interactively or sourced from another script, e.g:
> cat > foo.sh
> source environment-setup
> ^D
> 
> But I missed case when environment-setup is sourced from another directory,
> lucky this works in zsh case, but not in case of dash, ksh.
> So the fix would be applicable to zsh only (actually my main purpose for the
> patch).
> 
>>
>>   I think the only viable solution is to require an argument if shell is not
>> bash.
> So you are thinking of
> if [ $SHELL != bash ] ; then ?

 I was thinking of your if [ x"${BASH_SOURCE}" != x"" ]

 Regards,
 Arnout

> I don't know if that will be easy/portable to do  b/c running,
> 
> zsh
> bash
> env|grep SHELL
> SHELL=/bin/zsh
> XTERM_SHELL=/bin/zsh
> 
>>
>>   Regards,
>>   Arnout
>>
>>>
>>> Signed-off-by: Krzysztof Kanas <kkanas@fastmail.com>
>>> ---
>>>   package/environment-setup/environment-setup | 6 +++++-
>>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/package/environment-setup/environment-setup
>>> b/package/environment-setup/environment-setup
>>> index e9bc36fdd093..2b54e88d6689 100644
>>> --- a/package/environment-setup/environment-setup
>>> +++ b/package/environment-setup/environment-setup
>>> @@ -16,4 +16,8 @@ Some tips:
>>>   * To build CMake-based projects, use the "cmake" alias
>>>     EOF
>>> -SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}"))
>>> +if [ x"${BASH_SOURCE}" != x"" ]; then
>>> +        SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}"))
>>> +else
>>> +    SDK_PATH=$(dirname $(realpath $0))
>>> +fi
>>>
_______________________________________________
buildroot mailing list
buildroot@busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

  reply	other threads:[~2021-09-01 14:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30 20:13 [Buildroot] [PATCH 1/1] package/environment-setup/environment-setup: add zsh Krzysztof Kanas
2021-09-01 13:26 ` Arnout Vandecappelle
2021-09-01 14:48   ` Krzysztof Kanas
2021-09-01 14:59     ` Arnout Vandecappelle [this message]
2021-09-01 16:04       ` Krzysztof Kanas
     [not found]         ` <20210902112848.41512-1-kkanas@fastmail.com>
2021-09-11 14:53           ` [Buildroot] [PATCH v2 " Arnout Vandecappelle
2021-09-13 13:38           ` Peter Korsgaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81d1492a-d3ce-fc45-4227-4b05c0aeb4a0@mind.be \
    --to=arnout@mind.be \
    --cc=buildroot@buildroot.org \
    --cc=kkanas@fastmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.