Monthly Archives: November 2007

ash and select

Working on gc-utils, I discovered that bash, pdksh, ksh and zsh support the select statement, but ash doesnot.

The select statement creates a numbered list out of a list of words and let you choose one of them. This is done until a break statement is reached. The statement is a great way to create simple menus.

For example

select action in list show exit
do
echo $action
done

will generate a list in the form

1) list
2) show
3) exit
Select>

My /bin/sh (ash) doesn’t know that command. I didn’t tested it with csh or tcsh, as tcsh and csh doesn’t support functions and therefore I allready dropped the support for those shells completly. For ash, I created a workaround. Maybe it’s not the nicest solutions, but it works. If someone has a better way to solve the problem, just drop me a comment.

The following code generates a list of the sha1 commit ids that differ between two branches in git using git cherry-pick.

selecting ()
{
RESULT=””
while true
do
i=1
for word in $WORDS
do
echo “${i}) $word”
i=`expr $i + 1`
done
echo -n “Select> ”
read select
if test $i -gt $select
then
break
fi
done
i=1
for word in $WORDS
do
if test $i -eq $select
then
RESULT=$word
break
fi
i=`expr $i + 1`
done
}

WORDS=`git cherry origin | egrep -o -e “[a-f0-9]{40}.*”`; selecting; sha=$RESULT

I used that code for my multi commit tool, which wrapps the gc-commit tool, and makes it a lot more comfortable to commit back into cvs. The gc-multi-commit script is available at the experimental branch.

gc-utils – debian packages

Debian packages for gc-utils are now available from http://deb.experimentalworks.net. This makes installing and uninstalling more comfortable. Just download and run it with a graphical installer like gdebi or with command line tool executing:

$ wget http://deb.experimentalworks.net/gcutils_0.0.2-1_i386.deb
$ sudo dpkg -i gcutils_0.0.2-1_i386.deb

Comments are welcome.

gc-utils – interaction between cvs and git

The version control system GIT is powerfull but not yet widely used. In everyday life programers usually have to deal with centralized VCs, in particular CVS.

If you have to use CVS but want to get the advantages of GIT, you usually will import a CVS repository into GIT using git-cvsimport. Dealing with the cvs import and export scripts of GIT is pretty straight forward but yet a more or less complex task. To make things easier I wrote a small set of scripts, making the daily work with GIT and CVS easy and less complicated.

The toolset is called git-utils. It help you with importing an CVS into a GIT repository and keeping them up to day as well as commiting back into the CVS.

To install the toolset, download it. Then run:

$ tar zxvf gc-utils-master.tar.gz
$ cd gc-utils
$ make prefix=/usr install

You can now use gc-import, gc-update and gc-commit. Furthermore man pages are available. The toolset is available under a BSD/MIT License.

If you find the tools usefull, please drop a comment. Continue reading