Additional info
If we follow on symboli link /private/var/select/sh and assume that /bin/sh
in practice execute /bin/bash - the question arise - from where the default
PATH is set. Looking into /etc/profile I see:
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
and first position is /usr/libexec/path_helper -s
check the man path_helper and what I see - the default is taken from
/etc/paths and /etc/paths.d what is exactly the same what I see when I put
command echo $PATH | tr ':' '\n' into window "Run UNIX command"
Sorry for that long story - it is the result of switching 30-years
experienced UNIX person to macOS who is asking questions around :-)
Piotr
czwartek, 20 listopada 2025 o 21:50:22 UTC+1 Piotr Kolasiński napisał(a):
> I can't fully agree with your response.
> I understand differences between login shell, interactive shell and batch
> shell. But there are some additional details:
>
> - If you look into zsh documentation of zsh in point (
> https://zsh.sourceforge.io/Doc/Release/Invocation.html#Invocation) you
> will see statements: *Zsh tries to emulate sh or ksh when it is
> invoked as sh or ksh respectively; more precisely, it looks at the first
> letter of the name by which it was invoked, excluding any initial ‘r’
> (assumed to stand for ‘restricted’), and if that is ‘b’, ‘s’ or ‘k’ it
> will
> emulate sh or ksh. Furthermore, if invoked as su (which happens on certain
> systems when the shell is executed by the su command), the shell will try
> to find an alternative name from the SHELL environment variable and
> perform
> emulation based on that.*
> - ... and ... *The usual zsh startup/shutdown scripts are not
> executed. Login shells source /etc/profile followed by $HOME/.profile. If
> the ENV environment variable is set on invocation, $ENV is sourced after
> the profile scripts.*
>
> I've made some tests: put in files .profile and .zprofile command echo
> ".profile executed" / echo ".zprofile executed" and executed:
>
> - in terminal:
> - /bin/sh --> None
> - /bin/sh -l --> .profile executed
> - /bin/zsh --> Output from my .zshrc
> - /bin/zsh -l --> .zprofile executed and output from my .zshrc
> - /bin/zsh -i -->Output from my .zshrc
> - from BBEdit - command like echo "Hello world"
> - result Hello world - should be .zprofile executed as Bare Bones
> write in link pointing by you
> - The SHELL environment is set by the current shell *based on current
> login shell defined for user* as information for other processes
> which program to call when shell should be executed (in Linux/Unix -
> entry
> in /etc/passwd file) and not represents current executing shell - to test
> - just ran /bin/bash and check what will be set in SHELL
> - If you check man sh - you will see the it is the wrapper program
> which in practice call (exec inplace rather not spawn process) program
> pointed by symbolic link /private/var/select/sh - in my case it is ...
> */bin/bash*, please check in your system, in my opinion it also be
> /bin/bash. And in the case of bash the rules are the same - if it is
> running as /bin/sh (arg 0 provided to the process), bash all try to behave
> as /bin/sh - check man bash and look for sh (sorrounded by spaces) -
> part of man : *If bash is invoked with the name sh, it tries to mimic
> the startup behavior of historical versions of sh as closely as possible,
> while conforming to the POSIX standard as well.*
>
> If you verify all that things and agree with me, please consider to add
> additional mechanism and setup option to define how the "Run UNIX command"
> menu option should be executed
>
> Piotr
> czwartek, 20 listopada 2025 o 18:30:28 UTC+1 Rich Siegel napisał(a):
>
>> On 20 Nov 2025, at 12:08, Piotr Kolasiński wrote:
>>
>> > By running command inside "Run UNIX command" like:
>> > cat $0
>> > I see that in practice the command i prefixed by shebang #!/bin/sh, so
>> it
>> > means that real shell for execution is /bin/sh.
>>
>> If you use "Run Unix Command" to run `env`, you'll see that the active
>> shell is in fact `zsh`, provided that is your login shell.
>>
>> If your environment isn't what you expect it to be, you may need to make
>> some adjustments. Here's more on that:
>> https://www.barebones.com/support/bbedit/zshenv.html
>>
>> Enjoy,
>>
>> R.
>>
>>
>> --
>> Rich Siegel Bare Bones Software, Inc.
>> <[email protected]> <https://www.barebones.com/>
>>
>> Someday I'll look back on all this and laugh... until they sedate me.
>>
>
--
This is the BBEdit Talk public discussion group. If you have a feature request
or believe that the application isn't working correctly, please email
"[email protected]" rather than posting here. Follow @bbedit on Mastodon:
<https://mastodon.social/@bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/bbedit/7920beb1-b37a-4d39-9f58-4c51ce9f3fd5n%40googlegroups.com.