We made it possible. Next, we'll make it beautiful.
Suffering-oriented programming
- 柔軟性向上
- 予想以上に複雑な使い方をしているケースが多かったので、設定ファイルも複雑化して対応する
#!/bin/bash | |
export LANG=C | |
for service in $(/sbin/chkconfig --list | grep 3:on | awk '{ print $1 }') | |
do | |
while : | |
do | |
echo -n "disable $service ?: " | |
read answer | |
case $answer in | |
Y|y) |
require 'formula' | |
class Emacs < Formula | |
url 'http://ftp.gnu.org/pub/gnu/emacs/emacs-23.3a.tar.bz2' | |
md5 'f2cf8dc6f28f8ae59bc695b4ddda339c' | |
homepage 'http://www.gnu.org/software/emacs/' | |
if ARGV.include? "--use-git-head" | |
head 'git://repo.or.cz/emacs.git' | |
else |
#!/usr/bin/ruby | |
# vim:set fileencoding=utf-8 : | |
require 'shellwords' | |
ARGF.each do | |
|line| | |
line.chomp! | |
line.sub!(/\A.+?;/, '') rescue next | |
next unless m = line.match(/\Acd\s+(~?\/.*)/) |
We made it possible. Next, we'll make it beautiful.
Suffering-oriented programming
TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl
extension and a different #!
call.
The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect
we use the following:
#!/usr/bin/expect
EMACS_VER=24.3 | |
curl -O http://ftp.gnu.org/pub/gnu/emacs/emacs-${EMACS_VER}.tar.gz | |
curl -O https://gist.github.com/anonymous/8553178/raw/c0ddb67b6e92da35a815d3465c633e036df1a105/emacs.memory.leak.aka.distnoted.patch.diff | |
svn co http://svn.sourceforge.jp/svnroot/macemacsjp/inline_patch/trunk inline_patch | |
tar xvfz emacs-${EMACS_VER}.tar.gz | |
cd emacs-${EMACS_VER} |
http://d.stavrovski.net/blog/post/how-to-install-and-setup-oracle-java-jdk-in-centos-6 | |
# rpm | |
wget --no-cookies \ | |
--no-check-certificate \ | |
--header "Cookie: oraclelicense=accept-securebackup-cookie" \ | |
"http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.rpm" \ | |
-O jdk-7-linux-x64.rpm | |
# ubuntu |