Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

basename #32

@mmessmore

Description

@mmessmore

For usage messages and such in my shell scripts I typically use prog=${0##*/} instead of prog=$(basename $0).

dirname can similarly be replace with ${var%/*}.

You noted the ''#' and '%' string operations, but I though you may want to call out the opportunity to avoid firing off a process.

Excellent work. I'm sharing with the folks on my team newer to shell, as it is chock full of examples I have learned and taught myself back in the day when I had to write resource efficient scripts than ran on a bunch of Unixes and POSIX(ish) shells.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions