is.sh icon indicating copy to clipboard operation
is.sh copied to clipboard

Features, Maintainability, & Style changes

Open SidIcarus opened this issue 6 years ago • 4 comments
trafficstars

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 --version followed by --help
    • conditions
      • alias, builtin, keyword, function|fn, int|integer, array, hash|dictionary, export|exported
      • bool|boolean, truthy, falsey
      • cmd|command
      • in
      • set|var|variable
    • .editorconfig, .gitignore
    • test
      • can now be passed in multiple arguments to test against the same condition
  • maintainability

    • version & help are in their own function
      • printf over heredoc + cat
    • reused logic for several conditions
    • printf over echo
      • echo doesn'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
    • printf over heredoc to not have tabs or un-indented code
    • assert.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.

SidIcarus avatar Sep 05 '19 15:09 SidIcarus

Looking into the tests running on 3.2.57

SidIcarus avatar Sep 05 '19 16:09 SidIcarus

@qzb can you take a look?

SidIcarus avatar Sep 06 '19 17:09 SidIcarus

Thanks for your PR, I'll try to review it today or tomorrow, but for now it looks great 😀

qzb avatar Sep 11 '19 06:09 qzb

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.

SidIcarus avatar Sep 20 '19 14:09 SidIcarus