diff --git a/.bash_history b/.bash_history index e9534a7..29733f4 100644 --- a/.bash_history +++ b/.bash_history @@ -102,6 +102,7 @@ cd ~/dev/paperless/ # project cd ~/dev/paperless.wiki/ # project cd ~/dev/qr2scad/ # project cd ~/dev/schemaspy2svg/ # project +cd ~/dev/shell-includes/ # project cd ~/dev/shunit-ng/ # project cd ~/dev/Smooth-CoffeeScript/ # project cd ~/dev/subsurface/ # project @@ -421,6 +422,7 @@ git stash show git stash show --patch # diff git stash show --patch stash@{1} # diff git status +git submodule add git://github.com/l0b0/shell-includes.git git svn clone -s -r 1:HEAD http://svn/repo git svn clone -s -r 1:HEAD --no-minimize-url http://svn/repo/path git svn dcommit @@ -858,6 +860,7 @@ mkgithub ~/dev/rvm # ruby version manager mkgithub ~/dev/schemaspy2svg mkgithub ~/dev/screensaver-info mkgithub ~/dev/see-colon +mkgithub ~/dev/shell-includes mkgithub ~/dev/shunit-ng mkgithub ~/dev/SICP mkgithub ~/dev/Smooth-CoffeeScript diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7f5d751 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "shell-includes"] + path = shell-includes + url = git://github.com/l0b0/shell-includes.git diff --git a/README.markdown b/README.markdown index 818e75d..d622c90 100644 --- a/README.markdown +++ b/README.markdown @@ -7,7 +7,6 @@ These will probably be moved to separate projects after a while: * `tools.mk` - Auxiliary `make` targets. * `scripts/duplicates.sh` - Check for duplicate files in two directories. -* `scripts/functions.sh` - Auxiliary functions. * `scripts/install-all.sh` - Should probably be moved to `.bash_history`. * `scripts/make-links.sh` - Create symbolic links for several files in a separate directory, asking for confirmation or diffing if there is a collision. * `scripts/__svn_ps1.sh` - Similar to [`__git_ps1.sh`](), provides a string usable in Bash's `$PS1` when sourced while inside a Subversion repository. diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh index 1cbaa7b..b76c150 100755 --- a/scripts/cleanup.sh +++ b/scripts/cleanup.sh @@ -32,7 +32,7 @@ shopt -s nullglob directory="$(dirname -- "$0")" PATH='/usr/bin:/bin' -. "$directory/functions.sh" +. "$directory/../shell-includes/functions.sh" # Process parameters until [ $# -eq 0 ] diff --git a/scripts/duplicates.sh b/scripts/duplicates.sh index c35538b..9a9fd68 100755 --- a/scripts/duplicates.sh +++ b/scripts/duplicates.sh @@ -35,7 +35,7 @@ directory="$(dirname -- "$(readlink -fn -- "$0")")" -. "$directory/functions.sh" +. "$directory/../shell-includes/functions.sh" start_dir_x="$(readlink -fn -- "$1"; echo x)" start_dir="${start_dir_x%x}" diff --git a/scripts/functions.sh b/scripts/functions.sh deleted file mode 100644 index 31dcbeb..0000000 --- a/scripts/functions.sh +++ /dev/null @@ -1,107 +0,0 @@ -# NAME -# functions.sh - Utility functions for shell scripts -# -# SYNOPSIS -# . functions.sh -# -# BUGS -# https://github.com/l0b0/tilde/issues -# -# COPYRIGHT AND LICENSE -# Copyright (C) 2010-2012 Victor Engmark -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -################################################################################ - -# Exit codes from /usr/include/sysexits.h, as recommended by -# http://www.faqs.org/docs/abs/HTML/exitcodes.html -EX_USAGE=64 # command line usage error - -# Custom errors -EX_UNKNOWN=1 - -cmdname="$(basename -- "$0")" - -help_info="Try \`$cmdname --help\` for more information." - -warning() { - # Output warning messages - # Color the output red if it's an interactive terminal - # @param $1...: Messages - - test -t 1 && tput setf 4 - - printf '%s\n' "$@" >&2 - - test -t 1 && tput sgr0 # Reset terminal - true -} - -error() { - # Output error messages with optional exit code - # @param $1...: Messages - # @param $N: Exit code (optional) - - messages=( "$@" ) - - # If the last parameter is a number, it's not part of the messages - last_parameter="${messages[@]: -1}" - if [[ "$last_parameter" =~ ^[0-9]*$ ]] - then - exit_code=$last_parameter - unset messages[$((${#messages[@]} - 1))] - fi - - warning "${messages[@]}" - - exit ${exit_code:-$EX_UNKNOWN} -} - -usage() { - # Print documentation until the first empty line - # @param $1: Exit code (optional) - while IFS= read line - do - if [ -z "$line" ] - then - exit ${1:-0} - elif [ "${line:0:2}" == '#!' ] - then - # Shebang line - continue - fi - echo "${line:2}" # Remove comment characters - done < "$0" -} - -verbose_echo() { - # @param $1: Optionally '-n' for echo to output without newline - # @param $(1|2)...: Messages - if [ "${verbose-}" ] - then - if [ "${1-}" = "-n" ] - then - local -r newline='-n' - shift - fi - - while [ "${1+defined}" = defined ] - do - echo -e ${newline-} "$1" >&2 - shift - done - fi - true -} diff --git a/scripts/make-links.sh b/scripts/make-links.sh index 56ce1f3..87a0fc2 100755 --- a/scripts/make-links.sh +++ b/scripts/make-links.sh @@ -62,7 +62,7 @@ default_excludes=('\.' '\.\.' '\.git' '\.svn') directory="$(dirname -- "$0")" -. "$directory/functions.sh" +. "$directory/../shell-includes/functions.sh" # Process parameters params="$(getopt -o d:e:fshv \ diff --git a/shell-includes b/shell-includes new file mode 160000 index 0000000..07d089f --- /dev/null +++ b/shell-includes @@ -0,0 +1 @@ +Subproject commit 07d089f055e6ca17e5001fe38adee5944ae9ceb5 diff --git a/tests/tests.sh b/tests/tests.sh index b580a65..a98f8e0 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -34,7 +34,7 @@ shopt -s extglob directory="$(dirname -- "$0")" -. "$directory/../scripts/functions.sh" +. "$directory/../shell-includes/functions.sh" cd -- "$directory" for path in !(tests.sh)