Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.1.7 – new 0="…" snippet #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

psprint
Copy link
Contributor

@psprint psprint commented Jul 26, 2023

Description

When working with Zsh scripting in past years I've developed a better 0="…" snippet that the older, 2-line one. It works everywhere, be it a sourced script, hash-bang binary script or autoloaded function. is 1-line and is essentially better than the old one, which was difficult to understand because of $ZSH_ARGZERO reference.

Related Issue(s)

Motivation and Context

When one wants to get path to autoload function in order to get path to some share/… dir contents, he can:

my-function() {
    0=${${ZERO:-${(%):-%x}}:A}
    ls $0:h/share
}

How Has This Been Tested?

I've been using it in my projects: angel, tigsuite. zsh-sweep and others for about half of the year.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation change
  • New feature (non-breaking change which adds functionality)

Checklist:

  • All new and existing tests passed.
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant