From: Frank Terbeck Date: Wed, 26 Mar 2008 19:21:26 +0000 (+0100) Subject: Move version and system checking functions up in the file X-Git-Tag: 0.3.51~10 X-Git-Url: https://git.grml.org/?a=commitdiff_plain;h=595dd1e6e42c6fb8a005465c3c547c2f77a36f0c;hp=20a83b08a64ef033ac0a2b5aedcbe4af2b4fd3ee;p=grml-etc-core.git Move version and system checking functions up in the file I will need at least one of these earlier in the file and I do not see why not to define these almost as early as possible. --- diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 0a15eb2..b414c93 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -92,6 +92,99 @@ if [[ -n $ZSH_PROFILE_RC ]] ; then fi # }}} +# {{{ check for version/system +# check for versions (compatibility reasons) +is4(){ + [[ $ZSH_VERSION == <4->* ]] && return 0 + return 1 +} + +is41(){ + [[ $ZSH_VERSION == 4.<1->* || $ZSH_VERSION == <5->* ]] && return 0 + return 1 +} + +is42(){ + [[ $ZSH_VERSION == 4.<2->* || $ZSH_VERSION == <5->* ]] && return 0 + return 1 +} + +is43(){ + [[ $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0 + return 1 +} + +#f1# Checks whether or not you're running grml +isgrml(){ + [[ -f /etc/grml_version ]] && return 0 + return 1 +} + +#f1# Checks whether or not you're running a grml cd +isgrmlcd(){ + [[ -f /etc/grml_cd ]] && return 0 + return 1 +} + +if isgrml ; then +#f1# Checks whether or not you're running grml-small + isgrmlsmall() { + [[ ${${${(f)"$( autologin +# Thanks go to Bart Schaefer! +isgrml && checkhome() { + if [[ -z "$ALREADY_DID_CD_HOME" ]] ; then + export ALREADY_DID_CD_HOME=$HOME + cd + fi +} + +# check for zsh v3.1.7+ + +if ! [[ ${ZSH_VERSION} == 3.1.<7->* \ + || ${ZSH_VERSION} == 3.<2->.<->* \ + || ${ZSH_VERSION} == <4->.<->* ]] ; then + + printf '-!-\n' + printf '-!- In this configuration we try to make use of features, that only\n' + printf '-!- require version 3.1.7 of the shell; That way this setup can be\n' + printf '-!- used with a wide range of zsh versions, while using fairly\n' + printf '-!- advanced features in all supported versions.\n' + printf '-!-\n' + printf '-!- However, you are running zsh version %s.\n' "$ZSH_VERSION" + printf '-!-\n' + printf '-!- While this *may* work, it might as well fail.\n' + printf '-!- Please consider updating to at least version 3.1.7 of zsh.\n' + printf '-!-\n' + printf '-!- DO NOT EXPECT THIS TO WORK FLAWLESSLY!\n' + printf '-!- If it does today, you'\''ve been lucky.\n' + printf '-!-\n' + printf '-!- Ye been warned!\n' + printf '-!-\n' + + function zstyle() { : } +fi + +# }}} + # utility functions {{{ # this function checks if a command exists and returns either true # or false. This avoids using 'which' and 'whence', which will @@ -226,6 +319,14 @@ function zrcautoload() { #}}} +# Load is-at-least() for more precise version checks {{{ + +# Note that this test will *always* fail, if the is-at-least +# function could not be marked for autoloading. +zrcautoload is-at-least || is-at-least() { return 1 } + +# }}} + # locale setup {{{ if [[ -z "$LANG" ]] ; then xsource "/etc/default/locale" @@ -267,104 +368,6 @@ fi unset xof # }}} -# {{{ check for version/system -# check for versions (compatibility reasons) -is4(){ - [[ $ZSH_VERSION == <4->* ]] && return 0 - return 1 -} - -is41(){ - [[ $ZSH_VERSION == 4.<1->* || $ZSH_VERSION == <5->* ]] && return 0 - return 1 -} - -is42(){ - [[ $ZSH_VERSION == 4.<2->* || $ZSH_VERSION == <5->* ]] && return 0 - return 1 -} - -is43(){ - [[ $ZSH_VERSION == 4.<3->* || $ZSH_VERSION == <5->* ]] && return 0 - return 1 -} - -# Use is-at-least, if you need to check more precisely. -# Note that this test will *always* fail, if the is-at-least -# function could not be marked for autoloading. -zrcautoload is-at-least || is-at-least() { return 1 } - -#f1# Checks whether or not you're running grml -isgrml(){ - [[ -f /etc/grml_version ]] && return 0 - return 1 -} - -#f1# Checks whether or not you're running a grml cd -isgrmlcd(){ - [[ -f /etc/grml_cd ]] && return 0 - return 1 -} - -if isgrml ; then -#f1# Checks whether or not you're running grml-small - isgrmlsmall() { - [[ ${${${(f)"$( autologin -# Thanks go to Bart Schaefer! -isgrml && checkhome() { - if [[ -z "$ALREADY_DID_CD_HOME" ]] ; then - export ALREADY_DID_CD_HOME=$HOME - cd - fi -} - -# check for zsh v3.1.7+ - -if ! [[ ${ZSH_VERSION} == 3.1.<7->* \ - || ${ZSH_VERSION} == 3.<2->.<->* \ - || ${ZSH_VERSION} == <4->.<->* ]] ; then - - printf '-!-\n' - printf '-!- In this configuration we try to make use of features, that only\n' - printf '-!- require version 3.1.7 of the shell; That way this setup can be\n' - printf '-!- used with a wide range of zsh versions, while using fairly\n' - printf '-!- advanced features in all supported versions.\n' - printf '-!-\n' - printf '-!- However, you are running zsh version %s.\n' "$ZSH_VERSION" - printf '-!-\n' - printf '-!- While this *may* work, it might as well fail.\n' - printf '-!- Please consider updating to at least version 3.1.7 of zsh.\n' - printf '-!-\n' - printf '-!- DO NOT EXPECT THIS TO WORK FLAWLESSLY!\n' - printf '-!- If it does today, you'\''ve been lucky.\n' - printf '-!-\n' - printf '-!- Ye been warned!\n' - printf '-!-\n' - - function zstyle() { : } -fi - -# }}} - # {{{ set some variables if check_com -c vim ; then #v#