Skip to content

Conversation

@gaelicWizard
Copy link
Contributor

@gaelicWizard gaelicWizard commented Feb 14, 2022

Description

  • Replace echo -e with printf in _bash-it-log-message().
  • local positional parameters to allow for defaults.
  • Use new composure.sh feature to reduce load order dependency.
  • Use if/then properly.
  • Clean up use of $BASH_IT_LOG_PREFIX slightly (eliminate duplicate colons).

Motivation and Context

Misuse of &&/|| can cause unexpected return status, so I'm just fixing to use if/then wherever I see them. echo -e is unreliable and has differing behaviour in different contexts, such as in subshells and when xpg_echo is enabled. printf does exactly what it says on the tin. The parameter $message was leaking from every log function, so I local'd it. Alsö, local the rest of the parameters and fill in a default color, default log level, and strip duplicate colons from the message and level.

How Has This Been Tested?

Now that #1902 is merged, I can start a whole shell straight off master!! So, anyway, I have my $BASH_IT_LOG_LEVEL set to max in my ~/.bashrc so I see all the messages and everything still works.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.
  • If my change requires a change to the documentation, I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • If I have added a new file, I also added it to clean_files.txt and formatted it using lint_clean_files.sh.
  • I have added tests to cover my changes, and all the new and existing tests pass.

@gaelicWizard gaelicWizard marked this pull request as ready for review February 14, 2022 23:56
Copy link
Member

@NoahGorny NoahGorny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

- Replace `echo -e` with `printf` in `_bash-it-log-message()`.
- Local positional parameters to allow for defaults.
- Use `if`/`then` properly.
- Clean up use of `$BASH_IT_LOG_PREFIX` slightly (eliminate duplicate colons).
- these functions can now run even if `composure.sh` has *not* been loaded at all!
@NoahGorny NoahGorny merged commit 9d6fe72 into Bash-it:master Feb 16, 2022
@gaelicWizard gaelicWizard deleted the lib/log branch February 16, 2022 20:49
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.

2 participants