Skip to content

Commit

Permalink
[PATCH] Remove last bashisms from remaining commands.
Browse files Browse the repository at this point in the history
  Especially also simplify the (quite sloppy) loops to extract ranges of
lines, use sed -n -e '<min>,<max>p' for that.

Signed-off-by: Pierre Habouzit <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
  • Loading branch information
MadCoder authored and Josef 'Jeff' Sipek committed Jun 14, 2007
1 parent e3a4bcd commit ba83472
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 70 deletions.
7 changes: 3 additions & 4 deletions guilt-add
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2006, 2007
#

USAGE="<file>..."
. guilt
. `dirname $0`/guilt

if [ $# -lt 1 ]; then
usage
fi

git-add -- "$@"

exec git-add -- "$@"
6 changes: 3 additions & 3 deletions guilt-export
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Pierre Habouzit, 2007
#

USAGE="[<target_dir>]"
. guilt
. `dirname $0`/guilt

if [ $# -gt 1 ]; then
usage
Expand All @@ -19,7 +19,7 @@ trap "rm -rf \"$target_dir\"" 0
mkdir -p "$target_dir"

get_series | tee "$target_dir/series" | while read p; do
mkdir -p "`dirname $target_dir/$p`" 2> /dev/null || true
silent mkdir -p "`dirname $target_dir/$p`" || true
cp "$GUILT_DIR/$branch/$p" "$target_dir/$p"
done

Expand Down
6 changes: 3 additions & 3 deletions guilt-files
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (C) 2007 Yasushi SHOJI <[email protected]>
#

USAGE="[-v] [-a] [-l]"
. guilt
. `dirname $0`/guilt

opt_verbose=
opt_all=
Expand All @@ -26,7 +26,7 @@ do
done

IFS=:
if [ $opt_all ]; then
if [ -n "$opt_all" ]; then
cat $applied
else
tail -1 $applied
Expand Down
6 changes: 3 additions & 3 deletions guilt-fork
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2007
#

USAGE="[<new_name>]"
. guilt
. `dirname $0`/guilt

if [ $# -gt 1 ]; then
usage
Expand All @@ -28,7 +28,7 @@ else
| sed -r -e 's:(\.diff?|\.patch)$::')
num=$(echo "$base" | sed -nre 's:.*-([0-9]+)$:\1:'p)
[ -n "$num" ] || num=1
newpatch="${base%-$num}-$((num+1))${patch#$base}"
newpatch="${base%-$num}-$(($num+1))${patch#$base}"
fi

if [ -e "$GUILT_DIR/$branch/$newpatch" ]; then
Expand Down
13 changes: 7 additions & 6 deletions guilt-graph
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2007
#

USAGE="[<patchname>]"
. guilt
. `dirname $0`/guilt

if [ $# -gt 1 ]; then
usage
Expand All @@ -24,13 +24,14 @@ else
fi
fi

function getfiles
getfiles()
{
git-diff-tree -r "$1^" "$1" | tr '\t' ' ' | cut -d' ' -f6
}

cache="$GUILT_DIR/$branch/.graphcache.$$"
mkdir "$cache"
trap "rm -rf \"$cache\"" 0

echo "digraph G {"

Expand All @@ -39,7 +40,7 @@ current="$top"
while [ "$current" != "$base" ]; do
echo "# checking rev $current"

echo -n '' > "$cache/dep"
touch "$cache/dep"

getfiles $current | while read f; do
# hash the filename
Expand All @@ -51,7 +52,7 @@ while [ "$current" != "$base" ]; do
echo "$current" > "$cache/$fh"
done

cat "$cache/dep" | sort | uniq | while read h; do
sort -u "$cache/dep" | while read h; do
echo " \"${h:0:8}\" -> \"${current:0:8}\"; // ?"
done

Expand All @@ -60,4 +61,4 @@ done

echo "}"

rm -rf "$cache"
trap - 0
6 changes: 3 additions & 3 deletions guilt-help
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2007
#

DO_NOT_CHECK_BRANCH_EXISTENCE=1

USAGE="[<command> | <topic>]"
. guilt
. `dirname $0`/guilt

case $# in
0)
Expand All @@ -24,4 +24,4 @@ case $# in
;;
esac

man "$page"
exec man "$page"
6 changes: 3 additions & 3 deletions guilt-import
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2007
#

USAGE="[-P <patch> ] <patch_file>"
. guilt
. `dirname $0`/guilt

case "$1" in
-P)
Expand All @@ -17,7 +17,7 @@ case "$1" in
;;
esac

if [ $# -lt 1 -o $# -gt 3 -o -z "$newname" -o -z "$oldname" ]; then
if [ $# -lt 1 ] || [ $# -gt 3 ] || [ -z "$newname" ] || [ -z "$oldname" ]; then
usage
fi

Expand Down
6 changes: 3 additions & 3 deletions guilt-import-commit
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2007
#

USAGE="[<hash> | <since>..[<until>] | ..<until>]"
. guilt
. `dirname $0`/guilt

if [ $# -ne 1 -o -z "$1" ]; then
if [ $# -ne 1 ] || [ -z "$1" ]; then
die "You must specify a range of commits"
fi

Expand Down
15 changes: 8 additions & 7 deletions guilt-new
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2006, 2007
#

USAGE="[-f] [-s] [-e|-m message] <patchname>"
. guilt
. `dirname $0`/guilt

if [ $# -lt 1 -o $# -gt 4 ]; then
if [ $# -lt 1 ] || [ $# -gt 4 ]; then
usage
fi

Expand Down Expand Up @@ -80,10 +80,11 @@ mkdir_dir=`dirname "$GUILT_DIR/$branch/$patch"`
[ "$edit" = "t" ] && $editor "$GUILT_DIR/$branch/$patch"

if [ ! -z "$force" ]; then
cd "$TOP_DIR"
git-diff HEAD >> "$GUILT_DIR/$branch/$patch"
git-reset --hard HEAD > /dev/null
cd -
(
cd "$TOP_DIR"
git-diff HEAD >> "$GUILT_DIR/$branch/$patch"
git-reset --hard HEAD > /dev/null
)
fi

# insert the patch name into the series file
Expand Down
6 changes: 3 additions & 3 deletions guilt-next
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2006, 2007
#

USAGE=""
. guilt
. `dirname $0`/guilt

if [ $# -ne 0 ]; then
usage
fi

n=`wc -l < $applied`
n=`expr $n + 1`
n=$(($n + 1))

get_series | awk "{ if (NR == $n) print \$0}"

10 changes: 5 additions & 5 deletions guilt-patchbomb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2007
#

DO_NOT_CHECK_BRANCH_EXISTENCE=1

USAGE="[-n] [--in-reply-to <msgid>] [<hash> | <since>..[<until>] | ..<until>]"
. guilt
. `dirname $0`/guilt

while [ $# -gt 0 ]; do
case "$1" in
Expand Down Expand Up @@ -34,7 +34,7 @@ git-log --pretty=oneline "$r" | cut -c 1-8,41- | $pager

echo -n "Are these what you want to send? [Y/n] "
read n
if [ "$n" = "n" -o "$n" = "N" ]; then
if [ "$n" = "n" ] || [ "$n" = "N" ]; then
die "Aborting..."
fi

Expand Down Expand Up @@ -72,7 +72,7 @@ opts="$opts $to_opts"
# last possible point to abort!
echo -n "Proceed with patchbomb (this is the last chance to abort)? [y/N] "
read n
if [ "$n" != "y" -a "$n" != "Y" ]; then
if [ "$n" != "y" ] && [ "$n" != "Y" ]; then
die "Aborting..."
fi

Expand All @@ -93,5 +93,5 @@ fi
echo -n "Delete temporary directory? [Y/n] "
read n

[ "$n" = "n" -o "$n" = "N" ] && exit 0
[ "$n" = "n" ] || [ "$n" = "N" ] && exit 0
rm -rf $dir
16 changes: 6 additions & 10 deletions guilt-push
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2006, 2007
#

USAGE="[ -f ] [-a | --all | <patchname>]"
. guilt
. `dirname $0`/guilt

abort_flag="abort"


if [ "$1" == "-f" ]; then
if [ "$1" = "-f" ]; then
abort_flag=""
shift
fi
Expand All @@ -20,7 +20,7 @@ fi

patch="$1"

if [ "$patch" = "--all" -o "$patch" = "-a" ]; then
if [ "$patch" = "--all" ] || [ "$patch" = "-a" ]; then
# we are supposed to push all patches, get the last one out of
# series

Expand Down Expand Up @@ -52,12 +52,8 @@ fi
sidx=`wc -l < $applied`
sidx=`expr $sidx + 1`

idx=0
for p in `get_series`; do
idx=`expr $idx + 1`
[ $idx -lt $sidx ] && continue
[ $idx -gt $eidx ] && break

get_series | sed -n -e "${sidx},${eidx}p" | while read p
do
echo "Applying patch..$p"
if [ ! -f "$GUILT_DIR/$branch/$p" ]; then
die "Patch $patch does not exist. Aborting."
Expand Down
6 changes: 3 additions & 3 deletions guilt-series
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2006, 2007
#

USAGE="[-v]"
. guilt
. `dirname $0`/guilt

while case "$#" in 0) break ;; esac
do
Expand All @@ -17,7 +17,7 @@ do
shift
done

if ! [ $verbose ]; then
if ! [ -n "$verbose" ]; then
get_series
else
prefix="+"
Expand Down
12 changes: 3 additions & 9 deletions guilt-unapplied
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2006, 2007
#

USAGE=""
. guilt
. `dirname $0`/guilt

if [ $# -ne 0 ]; then
usage
Expand All @@ -13,10 +13,4 @@ fi
n=`wc -l < $applied`
n=`expr $n + 1`

idx=0
for p in `get_series`; do
idx=`expr $idx + 1`
[ $idx -lt $n ] && continue

echo $p
done
get_series | sed -n -e "$n,\$p"
7 changes: 2 additions & 5 deletions uninstall
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (c) 2007 Nur Hussein <[email protected]>
#
Expand All @@ -12,7 +12,4 @@ PRE=$1

shift

for x in "$@"
do
rm "$PRE/$x"
done
(cd $PRE; rm "$@")

0 comments on commit ba83472

Please sign in to comment.