Mistři v programování na #hovnokod

Kreativní kontrola, zda existuje adresář

ls ${BUILD_DIR}/*${VERSION}-${RELEASE}*.${PKG_TYPE} &>/dev/null && mkdir -p ${PRODUCT_PATH}/${PKG_TYPE}
ls ${BUILD_DIR}/*${VERSION}-${RELEASE}*.${PKG_TYPE} &>/dev/null && cp ${BUILD_DIR}/*${VERSION}-${RELEASE}*.${PKG_TYPE} ${PRODUCT_PATH}/${PKG_TYPE}

Anonymous,

pochází z docker entrypoint v psotgres Docker. vypíchl bychten první IF

file_env() {
	local var="$1"
	local fileVar="${var}_FILE"
	local def="${2:-}"
	if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
		echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
		exit 1
	fi
	local val="$def"
	if [ "${!var:-}" ]; then
		val="${!var}"
	elif [ "${!fileVar:-}" ]; then
		val="$(< "${!fileVar}")"
	fi
	export "$var"="$val"
	unset "$fileVar"
}


Anonymous,

Aneb jak si napsat vlastní konfigurační jazyk v bashi. Best bit: sed -n '/^conff./{s///;p}'

#!/bin/bash - 

set -o errexit
set -o nounset

for conffile in $(env | sed -n '/^conff./{s///;p}')
do
	eval $(awk -F'=' '{print "service=\"" $1 "\""; print "conffile=\"" $2 "\""}' <<<$conffile)

	if [ ! -f "$conffile.tmpl" ] ; then
		cp "$conffile" "$conffile.tmpl"
	fi

	perl -pe 's/%%([^%]+)%%/$ENV{$1}/' < "$conffile.tmpl" > "$conffile"
done

Anonymous,

Proč to udělat jednoduše když to de složitě :D

OPTIONS=("Install" "Update" "Delete" "PW Rese" "Quit")
select OPTION in "${OPTIONS[@]}"; do
  case "$REPLY" in
  1 | 2 | 3 | 4) break ;;
  5) errorQuit ;;
  *) errorContinue ;;
  esac
done
##
if [ "$OPTION" == "Install" ]; then
  INSTALL="Inst"
elif [ "$OPTION" == "Update" ]; then
  INSTALL="Updt"
elif [ "$OPTION" == "Remove" ]; then
  INSTALL="Rem"
elif [ "$OPTION" == "PW Reset" ]; then
  INSTALL="Res"
fi
##
if [ $INSTALL == "Inst" ]
    echo ""
elif [ $INSTALL == "Updt" ]; then
   echo ""
elif [ $INSTALL == "Rem" ]; then
   echo ""
elif [$INSTALL == "Res"]; then
   echo ""
fi

Anonymous,


Anonymous,