function go { if [ $1 = "--add" -o $1 = "--rem" ] ; then perl -e' use strict; use warnings; my ($key, $dir) = @ARGV; local $^I = ".bak"; local @ARGV = "$ENV{HOME}/.bashrc"; while (<>) { my $f = /^\s*# -- BEGIN GO CASES --/ .. /^\s*# -- END GO CASES --/; if (!$f || $f == 1) { } elsif ($f !~ /E/) { $_ = "" if /^\s*\(\Q$key\E\)/; } elsif ($dir) { my ($prefix) = /^(\s*)/; print("$prefix($key) cd $dir;;\n"); } } continue { print } ' $2 $3 else case $1 in # -- BEGIN GO CASES -- (tmp) cd $HOME/tmp;; (home) cd $HOME/home;; # -- END GO CASES -- esac fi }