Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/theme-and-appearance.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

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
Copy link
Member

Choose a reason for hiding this comment

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

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

# On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
# with color and multibyte support) are available from ports. "colorls"
# will be installed on purpose and can't be pulled in by installing
Expand Down
2 changes: 1 addition & 1 deletion plugins/battery/battery.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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* ]] ; then

function battery_is_charging() {
! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
Expand Down
2 changes: 1 addition & 1 deletion plugins/gitfast/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2771,6 +2771,6 @@ __git_complete gitk __gitk_main
# when the user has tab-completed the executable name and consequently
# included the '.exe' suffix.
#
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
if [[ "$OSTYPE" = cygwin* ]]; then
__git_complete git.exe __git_main
fi
2 changes: 1 addition & 1 deletion plugins/sublime/sublime.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [[ $('uname') == 'Linux' ]]; then
if [[ "$OSTYPE" == linux* ]]; then
local _sublime_linux_paths > /dev/null 2>&1
_sublime_linux_paths=(
"$HOME/bin/sublime_text"
Expand Down
4 changes: 2 additions & 2 deletions plugins/zsh-navigation-tools/_n-kill
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ integer cygwin=0
local IFS="
"

case "$(uname)" in
CYGWIN*) list=( `command ps -Wa` ); cygwin=1 ;;
case "$OSTYPE" in
cygwin*) list=( `command ps -Wa` ); cygwin=1 ;;
*) list=( `command ps -o pid,uid,command -A` ) ;;
esac

Expand Down
4 changes: 2 additions & 2 deletions plugins/zsh-navigation-tools/n-kill
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ NLIST_NONSELECTABLE_ELEMENTS=( 1 )

type ps 2>/dev/null 1>&2 || { echo >&2 "Error: \`ps' not found"; return 1 }

case "$(uname)" in
CYGWIN*) list=( `command ps -Wa` ) ;;
case "$OSTYPE" in
cygwin*) list=( `command ps -Wa` ) ;;
*) list=( `command ps -o pid,uid,command -A` ) ;;
esac

Expand Down