Use OSTYPE instead of uname whenever possible for better speed. #5496

Merged
merged 1 commit into from Oct 10, 2016

Projects

None yet

2 participants

@xuhdev
Contributor
xuhdev commented Oct 5, 2016

No description provided.

@mcornella

In general 👍 but there are a couple things I'm not sure about.

@@ -6,11 +6,11 @@ export LSCOLORS="Gxfxcxdxbxegedabagacad"
if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
# Find the option for using colors in ls, depending on the version
- if [[ "$(uname -s)" == "NetBSD" ]]; then
+ if [[ "$OSTYPE" == netbsd* ]]; then
@mcornella
mcornella Oct 10, 2016 Collaborator

I'm not sure that's right, I don't have NetBSD machines to test with.

@xuhdev
xuhdev Oct 10, 2016 Contributor

Zsh OSTYPE comes from autoconf's host_os, and autoconf uses host_os to specify the bsds in this way. The BSD OSTYPEs here should be correct.

@mcornella
mcornella Oct 10, 2016 Collaborator

Great finding! I was just trying a NetBSD LiveUSB so this spares me a lot of suffering 🎉

# On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
gls --color -d . &>/dev/null && alias ls='gls --color=tty'
- elif [[ "$(uname -s)" == "OpenBSD" ]]; then
+ elif [[ "$OSTYPE" == openbsd* ]]; then
@mcornella
mcornella Oct 10, 2016 Collaborator

Same here, I don't have OpenBSD machines to test this.

plugins/battery/battery.plugin.zsh
@@ -64,7 +64,7 @@ if [[ "$OSTYPE" = darwin* ]] ; then
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
}
-elif [[ $(uname) == "Linux" ]] ; then
+elif [[ "$OSTYPE" = linux-gnu* ]] ; then
@mcornella
mcornella Oct 10, 2016 Collaborator

Just linux* will do.

@xuhdev
xuhdev Oct 10, 2016 Contributor

Done!

plugins/sublime/sublime.plugin.zsh
@@ -1,4 +1,4 @@
-if [[ $('uname') == 'Linux' ]]; then
+if [[ "$OSTYPE" == linux-gnu* ]]; then
@mcornella
mcornella Oct 10, 2016 Collaborator

Same, linux*

@xuhdev
xuhdev Oct 10, 2016 Contributor

I changed this to *-gnu*, because this plugin is really looking for a GNU env, not a Linux env. Setting this incorrectly would break kFreeBSD, which has a BSD kernel and GNU userland.

@xuhdev
xuhdev Oct 10, 2016 Contributor

I changed it to linux* now. Seems I have misunderstood this plugin before.

@mcornella mcornella merged commit a56eac7 into robbyrussell:master Oct 10, 2016
@foobacca foobacca pushed a commit to foobacca/oh-my-zsh that referenced this pull request Oct 11, 2016
Hamish Downer Merge remote-tracking branch 'origin/master' into personal
* origin/master:
  Fix ls coloring in MacOS if gls is not installed
  Fix ls colouring for Darwin. (#5516)
  Use $+commands to check the existence of a command in clipboard.zsh. (#5519)
  Use OSTYPE instead of uname whenever possible for better speed. (#5496)
  Take advantage of LS_COLORS for the color of completion if GNU ls is used. (#5510)
  remove duplicate alias (#5508)
  Add m4a format in the common aliases plugin (#5502)
  Add non 0 exit code for missing jump targets (#5500)
  Fix compdef commands in git plugin
  Update per-directory-history plugin to latest version (#5493)
  Fix formatting and usage section
  fix comment
  README for globalias
  specify globalias modes
  globalias fix #4834
08eeb31
@freecastle freecastle added a commit to freecastle/oh-my-zsh that referenced this pull request Oct 17, 2016
@freecastle freecastle Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh
* 'master' of https://github.com/robbyrussell/oh-my-zsh: (33 commits)
  Update bira theme (#4954)
  Display suvash prompt w/o Ruby; refactor code
  readme change OS X to macOS
  Fix ls coloring in MacOS if gls is not installed
  Fix ls colouring for Darwin. (#5516)
  Use $+commands to check the existence of a command in clipboard.zsh. (#5519)
  Use OSTYPE instead of uname whenever possible for better speed. (#5496)
  Take advantage of LS_COLORS for the color of completion if GNU ls is used. (#5510)
  remove duplicate alias (#5508)
  Add m4a format in the common aliases plugin (#5502)
  Add non 0 exit code for missing jump targets (#5500)
  Fix compdef commands in git plugin
  Update per-directory-history plugin to latest version (#5493)
  Fix formatting and usage section
  fix comment
  README for globalias
  specify globalias modes
  Fix style of theme-and-appearance.zsh
  Only set default LS_COLORS if not set before
  Use `$commands[]` to check for command existence
  ...
d9f9b16
@akharlamov akharlamov added a commit to akharlamov/oh-my-zsh that referenced this pull request Oct 23, 2016
@akharlamov akharlamov Merge remote-tracking branch 'upstream/master'
* upstream/master: (86 commits)
  Change from OSX to macOS in README (#5545)
  Update README with grammar corrections (#5503)
  Fix regex for optional http(s), and variable reference inside osascript.
  Update bira theme (#4954)
  Display suvash prompt w/o Ruby; refactor code
  readme change OS X to macOS
  Fix ls coloring in MacOS if gls is not installed
  Fix ls colouring for Darwin. (#5516)
  Use $+commands to check the existence of a command in clipboard.zsh. (#5519)
  Use OSTYPE instead of uname whenever possible for better speed. (#5496)
  Take advantage of LS_COLORS for the color of completion if GNU ls is used. (#5510)
  remove duplicate alias (#5508)
  Add m4a format in the common aliases plugin (#5502)
  Add non 0 exit code for missing jump targets (#5500)
  Fix compdef commands in git plugin
  Update per-directory-history plugin to latest version (#5493)
  Fix formatting and usage section
  fix comment
  README for globalias
  specify globalias modes
  ...
50f4f3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment