• 3 Posts
  • 1.23K Comments
Joined 11 months ago
cake
Cake day: May 30th, 2025

help-circle















  • Yeah, that was the lazy answer. The more correct is, because grass contains stuff (mainly lignin, reminds me of this i found this morning) that’s hard to digest with a normal stomach. So cows & co. have multiple gastric … sections(? Mägen), the first of which contains microrganisms specialized in breaking down lignin. The following gastrics are more the usual bio-chemical kind, to digest the microorganisms.

    In short, eating grass needs a specialized process and you can’t eat anything else as main food source, (they do occasionally eat a chicken or critter).





  • Sorry, late to the party. I like to use variations of them for debugging:

    red="$(tput setaf 1)"
    #green="$(tput setaf 2)"
    yellow="$(tput setaf 3)"
    blue="$(tput setaf 4)"
    reset="$(tput sgr0)"
    
    messg() { printf '%-20s\t%s\n' "$1" "$2"; }
    warn() { messg "${yellow}Warn${reset}:" "$1"; }
    error() { messg "${red}Error:" "$1" >&2; [ -n "$2" ] && exit "$2"; } # complain to STDERR and exit if given code
    debug() { [ -n "$debug" ] && messg "${blue}$1${reset}" "$2"; }
    
    [ "$debug" = "verbose" ] && set -x
    if [ -n "$debug" ]; then
    	alias rm='rm -v'
    	alias mv='mv -v'
    	alias mkdir='mkdir -v'
    	alias ln='ln -v'
    fi
    

    And those for config/state management:

    get_state() { grep "$1" "$state_file" 2>/dev/null |cut -d':' -f2; }
    set_state() { printf '%s:%s\n' "$1" "$2" >> "$state_file"; }
    
    get_conf() { cut -d'#' -f1 "$config_file" |grep -- "$1" |cut -d"=" -f2- ; }
    set_conf() {
            #: gracefully sets config options
            #: meaning: changes value if key exists, creates it if not
    	key="$1" value="$2" config="$config_file"
    	if grep -Eq "${key}=" "$config"
    		then sed -Ei "s/$key=.*/$key=$value/g" "$config"
    		else printf '%s=%s\n' "$key" "$value" >> "$config"
    	fi
    }
    

    And a few more:

    isexec() { [ -x "$(command -v "$1" 2>/dev/null)" ]; }
    contains() { case "$1" in *${2}*) return 0;; *) return 1;; esac; }