Skip to content

Commit

Permalink
Claude: The issue is in the zsh detection code. In zsh, $0 doesn't wo…
Browse files Browse the repository at this point in the history
…rk the same way as bash for detecting if a script is sourced. Let's patch it to fix zsh sourcing detection.
  • Loading branch information
ColinNg committed Jan 1, 2025
1 parent 0427d9a commit 70cb596
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ok.sh
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ environment variables (for internal use):
}

is_sourced=""
if [ "${ZSH_ARGZERO:+IS_SET}" = "IS_SET" ]; then
if [ "$ZSH_ARGZERO" = "zsh" ]; then
if [ -n "$ZSH_VERSION" ]; then
# For zsh, check if script name matches $0
if [[ "${(%):-%N}" == *"ok.sh" ]]; then
is_sourced="yes_indeed"
fi
else
Expand Down

0 comments on commit 70cb596

Please sign in to comment.