Thread: [Assorted-commits] SF.net SVN: assorted: [292] shell-tools/trunk/src/bash-commons/common.bash
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-02-02 09:11:02
|
Revision: 292 http://assorted.svn.sourceforge.net/assorted/?rev=292&view=rev Author: yangzhang Date: 2008-02-02 01:11:05 -0800 (Sat, 02 Feb 2008) Log Message: ----------- added `trace` Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2008-02-02 09:10:36 UTC (rev 291) +++ shell-tools/trunk/src/bash-commons/common.bash 2008-02-02 09:11:05 UTC (rev 292) @@ -322,6 +322,11 @@ rm "$a" } +trace() { + echo "$@" + "$@" +} + persist-fsc() { local output="$(fsc "$@")" || status="$$" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:42:02
|
Revision: 462 http://assorted.svn.sourceforge.net/assorted/?rev=462&view=rev Author: yangzhang Date: 2008-02-16 13:42:07 -0800 (Sat, 16 Feb 2008) Log Message: ----------- added is-empty, rm-empty Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2008-02-16 21:41:42 UTC (rev 461) +++ shell-tools/trunk/src/bash-commons/common.bash 2008-02-16 21:42:07 UTC (rev 462) @@ -350,6 +350,18 @@ fi } +is-empty() { + [[ -f "$1" && "$( stat -c%s "$1" )" == 0 ]] +} + +rm-empty() { + for i in "$@" ; do + if is-empty "$i" + then rm "$i" + fi + done +} + #if ! is_declared indent ; then # noindent #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-29 03:31:41
|
Revision: 524 http://assorted.svn.sourceforge.net/assorted/?rev=524&view=rev Author: yangzhang Date: 2008-02-28 19:31:47 -0800 (Thu, 28 Feb 2008) Log Message: ----------- added named, parent-dir (for assorted.bash) Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2008-02-29 03:31:33 UTC (rev 523) +++ shell-tools/trunk/src/bash-commons/common.bash 2008-02-29 03:31:47 UTC (rev 524) @@ -350,6 +350,24 @@ fi } +# For use with parent-dir. +named() { + [[ "$( basename "$( realpath "$2" )" )" == "$1" ]] && return 0 || return 1 +} + +# Recursively search parent directories until a directory is found that +# satisfies the given predicate. The predicate is the command formed from the +# arguments passed in. +parent-dir() { + local dir=. + while true ; do + if "$@" "$dir" ; then break ; fi + if [[ "$( realpath "$dir" )" == / ]] ; then return 1 ; fi + dir="$dir/.." + done + echo "$dir" +} + is-empty() { [[ -f "$1" && "$( stat -c%s "$1" )" == 0 ]] } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-03-03 04:29:44
|
Revision: 576 http://assorted.svn.sourceforge.net/assorted/?rev=576&view=rev Author: yangzhang Date: 2008-03-02 20:29:50 -0800 (Sun, 02 Mar 2008) Log Message: ----------- added run-if-def Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2008-03-03 04:29:39 UTC (rev 575) +++ shell-tools/trunk/src/bash-commons/common.bash 2008-03-03 04:29:50 UTC (rev 576) @@ -380,6 +380,12 @@ done } +run-if-def() { + if type "$1" >& /dev/null + then "$@" + fi +} + # Given a regex sub-pattern and a set of files, print a sorted list of all the # words (symbols) in those files that contain that sub-pattern. Example: # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-05-13 22:43:14
|
Revision: 807 http://assorted.svn.sourceforge.net/assorted/?rev=807&view=rev Author: yangzhang Date: 2008-05-13 15:43:21 -0700 (Tue, 13 May 2008) Log Message: ----------- added pyinstall() Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2008-05-13 22:43:13 UTC (rev 806) +++ shell-tools/trunk/src/bash-commons/common.bash 2008-05-13 22:43:21 UTC (rev 807) @@ -425,6 +425,12 @@ done } +pyinstall() { + local prefix="$1" pkgdir="$1/lib/python2.5/site-packages" + mkdir -p $pkgdir + PYTHONPATH="$pkgdir:$PYTHONPATH" ./setup.py install --prefix "$prefix" +} + #if ! is_declared indent ; then # noindent #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-05-13 22:46:59
|
Revision: 808 http://assorted.svn.sourceforge.net/assorted/?rev=808&view=rev Author: yangzhang Date: 2008-05-13 15:47:02 -0700 (Tue, 13 May 2008) Log Message: ----------- added some documentation to shell tools; removed indent etc Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2008-05-13 22:43:21 UTC (rev 807) +++ shell-tools/trunk/src/bash-commons/common.bash 2008-05-13 22:47:02 UTC (rev 808) @@ -161,18 +161,6 @@ silence type "$@" } -#indent() { -# let ++indent || true -#} -# -#deindent() { -# let --indent || true -#} -# -#noindent() { -# indent=0 -#} - log() { echo "$@" } @@ -265,8 +253,9 @@ rsync -e ssh -u -a --delete "$@" } +# Find and remove all broken links in the given directory (and subdirs). rm-broken-symlinks() { - find . -type l | + find "$@" -type l | while read file ; do if [ ! -e "$file" ] ; then sudo -u pkg rm "$file" @@ -274,6 +263,7 @@ done } +# XXX figure out wtf this is for. make this more general? populate-prefix-dir() { local target="$1" for j in bin info lib man src usr ; do @@ -294,6 +284,8 @@ # the GNU version: sed ':a; $!N; s/\n/ /; ta' } +# Parses a classpath from an Eclipse .classpath file (first arg) and sets the +# CLASSPATH variable accordingly for the subsequent command. get-classpath() { local classpath_file="$1" shift @@ -301,6 +293,7 @@ join-lines : ):$CLASSPATH" "$@" } +# Find the first available DNS name. XXX make this more general find-first-avail-name() { for i in {a..z}; do for j in {a..z}; do @@ -406,13 +399,12 @@ sort -u } +# bbfix, by Patrick Reynolds (reynolds .at. cs duke edu) +# Too trivial to copyright. It's in the public domain! +# +# Usage: +# ./bbfix foo.eps bbfix() { - # bbfix, by Patrick Reynolds (reynolds .at. cs duke edu) - # Too trivial to copyright. It's in the public domain! - # - # Usage: - # ./bbfix foo.eps - if [ $# = 0 ]; then echo "Usage:" echo " $0 file.eps [file.eps [file.eps [...]]]" @@ -425,6 +417,8 @@ done } +# Install a python package to the specified directory. Takes care of creating +# the dir and setting the PYTHONPATH appropriately for the setup process. pyinstall() { local prefix="$1" pkgdir="$1/lib/python2.5/site-packages" mkdir -p $pkgdir This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-05-14 22:57:14
|
Revision: 819 http://assorted.svn.sourceforge.net/assorted/?rev=819&view=rev Author: yangzhang Date: 2008-05-14 15:57:12 -0700 (Wed, 14 May 2008) Log Message: ----------- added cprestore() Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2008-05-14 22:56:50 UTC (rev 818) +++ shell-tools/trunk/src/bash-commons/common.bash 2008-05-14 22:57:12 UTC (rev 819) @@ -115,6 +115,15 @@ done } +cprestore() { + eval "$get_all_opts" + for file in "$@" ; do + file="$( echo "$file" | sed 's/\/\+$//' )" + echo cp $opts "$file" "${file%.backup}" + cp $opts "$file" "${file%.backup}" + done +} + # backup file(s) by moving bkup() { eval "$get_all_opts" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-05-14 22:57:28
|
Revision: 820 http://assorted.svn.sourceforge.net/assorted/?rev=820&view=rev Author: yangzhang Date: 2008-05-14 15:57:35 -0700 (Wed, 14 May 2008) Log Message: ----------- added check_private() Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2008-05-14 22:57:12 UTC (rev 819) +++ shell-tools/trunk/src/bash-commons/common.bash 2008-05-14 22:57:35 UTC (rev 820) @@ -434,6 +434,12 @@ PYTHONPATH="$pkgdir:$PYTHONPATH" ./setup.py install --prefix "$prefix" } +# Check that a file exists and has private permissions. +check_private() { + local path="$@" + (( "$( find "$path" -perm u=rw | wc -l )" == 1 )) +} + #if ! is_declared indent ; then # noindent #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-07-07 21:37:49
|
Revision: 879 http://assorted.svn.sourceforge.net/assorted/?rev=879&view=rev Author: yangzhang Date: 2008-07-07 14:37:58 -0700 (Mon, 07 Jul 2008) Log Message: ----------- added clear-ntfs-perms Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2008-07-07 21:37:48 UTC (rev 878) +++ shell-tools/trunk/src/bash-commons/common.bash 2008-07-07 21:37:58 UTC (rev 879) @@ -444,6 +444,21 @@ (( "$( find "$path" -perm u=rw | wc -l )" == 1 )) } +# Reading NTFS file systems (through ntfs-3g at least; don't know if this is +# inherent with NTFS in general) shows all files and directories as having +# completely set permissions (777). These stick if you move/copy the files. +# This resets the permissions. +# +# Note that this is not a panacea; there may well be files that you want to +# remain executable, or files/directories that you wish to leave +# group-/world-writeable. +clear-ntfs-perms() { + for dir in "${@:-.}" ; do + find "$dir" -type d -perm 777 -print0 | xargs -0r chmod 755 + find "$dir" -not -type d -perm 777 -print0 | xargs -0r chmod 644 + done +} + #if ! is_declared indent ; then # noindent #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |