#!/bin/bash # # Syntax: figl2eps [-h] [-c] [-d ps_dir] [n] # # Purpose: Transforms the n most recently changed .fig files into .eps # files using fig2eps. # The .eps files are placed in ~/fig/ps or, if the -d flag is # specified, in ps_dir (where ps_dir is an absolute or relative # path name). # By default the fig files are taken from ~/fig/xfig. # However, if the -c flag is given, then the fig files are taken # from the current directory and the output is placed into the # current directory; if in addition -d is specified the .eps files # are created in the ps_dir subdirectory of the current directory. # The -h flag shows the help info for this command. # # See also: fig2eps, figl2ps # Created: May 19, 1995 by Bart De Schutter # Last revised: Jan 2, 2011 by Bart De Schutter # # See http://www.deschutter.info/util/scripts.html for the latest version of # this script. # Status: public # Category: xfig # # Process input arguments. # fig_dir=~/fig/xfig fig2eps_options="" while getopts :hcd: option do case "$option" in h) sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 ;; c) fig_dir=$(pwd) fig2eps_options="$fig2eps_options -c" ;; d) fig2eps_options="$fig2eps_options -d ${OPTARG}" ;; :) echo >&2 echo >&2 "Option -$OPTARG requires an argument." echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 echo >&2 exit 1 ;; \?) echo >&2 echo >&2 "Unknown option: $OPTARG" echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 ;; esac done shift $(($OPTIND-1)) if [ $# -eq 0 ] then n=1 else n=$1 case $n in [0-9]* ) ;; * ) echo >&2 echo >&2 "ERROR: n should be a number." echo >&2 exit 1 esac fi # # Find the $n most recent fig files, and do some processing in order # to be able to deal with files that contain a space in their name. # fig_files=$( cd "$fig_dir" ; ls -t *.fig 2>/dev/null | \ head -n $n | sed -e 's/ /\\ /g' | tr "\n" " " ) if [ -z "$fig_files" ] then echo "No fig files found." else eval fig2eps -v $fig2eps_options $fig_files fi