is.sh
is.sh copied to clipboard
Features, Maintainability, & Style changes
Note
I kept cmd|command separate from available|installed for two reasons:
- to not break backward compatibility
- because really determining if a command is available, installed, or is just command, is more complicated; see has
I intended for these changes to be separate PR's but I got caught up and it got a little too tedious to re-structure the commits.
Since this doesn't break backwards compatibility, I've updated the version from 1.1.2 -> 1.2.0
Changes
-
features
- options:
- no args will display
--versionfollowed by--help
- no args will display
- conditions
alias,builtin,keyword,function|fn,int|integer,array,hash|dictionary,export|exportedbool|boolean,truthy,falseycmd|commandinset|var|variable
.editorconfig,.gitignore- test
- can now be passed in multiple arguments to test against the same condition
- options:
-
maintainability
version&helpare in their own functionprintfoverheredoc+cat
- reused logic for several conditions
printfoverechoechodoesn't consistently behave the same across all systems
- use builtin/internal functionality from bash over external tools
- since this tool doesn't check dependencies, it'll be safer
- removed duplicate codes
-
style
- spacing: 4 -> 2
printfoverheredocto not have tabs or un-indented codeassert.sh: move code continuation so syntax highlighting in VSCode doesn't mis-color the rest of the file
In the tests file, I kept reference to a bash bug I encountered when parsing the keyword & builtin, [[]] & [], respectively. I can add a note about what version this was found in.
Looking into the tests running on 3.2.57
@qzb can you take a look?
Thanks for your PR, I'll try to review it today or tomorrow, but for now it looks great 😀
Some of new conditions work only when script is sourced. I think it should be described in README.md and help messages. Personally I would move all this conditions to separate section in README.
Good idea. I'll fix up the tests to reflect this as well.