moved everything into /trunk/ to create the standard svn layout, for use with tools that require this (eg. git-svn). IMPORTANT: do NOT do an `svn up`. instead, re-use your working copy's existing files with `svn switch` (http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.switch.html).
fix: lib/sh/util.sh: verbosity_min(): usage: clarified that '' is a special value that causes $verbosity to be overwritten to ''
lib/sh/util.sh: stderr2stdout(): documented that this redirects fd 2->1 and log_fd (but not back to 2)
bugfix: lib/sh/util.sh: stderr2stdout() use `command` before tee, which re-filters log_fd so that stderr itself is also filtered. this allows log-filtering out an otherwise-confusing benign error when using e.g. stderr_matches().
lib/sh/util.sh: added not(), for use in prefixing wrapped commands
lib/sh/util.sh: added stderr_matches()
lib/sh/util.sh: documented that fds 2x/3x should not be used because we use these, as opposed to 1x which is used by the shell internally
lib/sh/util.sh: added stdout_contains()
lib/sh/util.sh: added stderr2stdout()
lib/sh/util.sh: import_vars: don't overwrite vars that are already defined, to allow the caller to specify their own values for the vars to create. this requires callers that rely on the overwriting functionality to reverse the order in which they run use_* commands, so that the higher-precedence use_* is applied first and the other one as the default values for the first.
lib/sh/util.sh: already_exists_msg(): added instructions on how to force-remake when the file already exists (prepend `rm=1` to the command)
lib/sh/util.sh: added require_dot_script()
bugfix: lib/sh/util.sh: $top_script: use @BASH_SOURCE instead of $0, because this is also defined for .-scripts
bugfix: lib/sh/util.sh: is_dot_script(): need to subtract 1 from ${#BASH_LINENO[@]}, because this is the array length rather than the index of the last element as in Perl
lib/sh/util.sh: added is_dot_script()
bugfix: lib/sh/util.sh: alias_append(): need to enclose $(alias) call in "" because its result may contain separator chars (i.e. whitespace) that will be parsed incorrectly. this appears to only be a bug when runscripts are run as shell-includes, with a leading ".".
lib/sh/util.sh: added instructions for making an export only visible locally
bugfix: lib/sh/util.sh: set_fds(): don't add surrounding quotes to empty redirect dest
bugfix: lib/sh/util.sh: set_fds(): need to check if redirect is empty before escaping it with `printf %q`, which may add surrounding quotes to an empty string
bugfix: lib/sh/util.sh: set_fds(): need to escape redirect destinations which are files, because they may contain special shell characters
lib/sh/util.sh: added rm_prefix()
lib/sh/util.sh: is_array(): handle unset vars (=false). this fixes a bug in pg_export_table_no_header, which produced the error "lib/sh/util.sh: line 290: declare: cols: not found".
fix: lib/sh/util.sh: join(): documented that delim must be a single char
bugfix: lib/sh/util.sh: set_fds(): remove empty redirects resulting from using `redirs= cmd...` to clear the redirs and then using $redirs as an array
fix: lib/sh/util.sh: set_fds(): documented that it does not currently support redirecting an fd to itself (due to bash bugs that require the dest fd to be closed before it can be reopened)
bugfix: lib/sh/util.sh: stdout2fd(): don't add >&$fd redirect if the fd is 1, because redir does not currently support redirecting an fd to itself (due to bash bugs that require the dest fd to be closed before it can be reopened)
lib/sh/util.sh: filter_fd(): factored out >() subshell command into stdout2fd() for clarity
bugfix: lib/sh/util.sh: redir(): unset redirs so that you don't redirect again in the invoked command
fix: lib/sh/util.sh: filter_fd(): documented that ${redirs[@]} must not be set to an outer value
bugfix: lib/sh/util.sh: pf(): echo func decl to stderr instead of stdout
lib/sh/util.sh: echo_vars(): documented that it only prints vars that are defined
lib/sh/util.sh: local_inv: also echo_vars the new var
lib/sh/util.sh: $sed_cmd: added usage
bugfix: lib/sh/util.sh: $sed_cmd: make output unbuffered, so that running e.g. bin/my2pg at the command line produces output as each line is read
lib/sh/util.sh: added is_array()
lib/sh/util.sh: moved runscript-related commands to lib/runscripts/util.run because these only apply to runscripts
bugfix: lib/sh/util.sh: sed: must use alias instead of function because function causes segfault in redir() subshell when used with make.sh make() filter (may be bug in bash?). this involves translating `unset LANG` to `env LANG=` (`env -u` to unset a var isn't supported on Mac, but fortunately sed treats LANG="" the same as unset LANG).
bugfix: lib/sh/util.sh: sed: unset LANG to avoid "illegal byte sequence" errors on invalid UTF-8 for LANG=*.UTF-8. these occur e.g. with MySQL data that is in Latin-1.
lib/sh/util.sh: sed: use function instead of alias so that env can be set up before calling sed
*{.sh,run}: use new log-() instead of log+() with a negative #
lib/sh/util.sh: added log-() because it's non-obvious that you would otherwise have to invoke log+() with a negative #
lib/sh/util.sh: added canon_dir_rel_path(), which canonicalizes just the parent dir if the path is a symlink, to leave the symlink itself untouched
lib/sh/util.sh: added self_name alias and use it in self/self_sys
lib/sh/util.sh: added sys_cmd_path() and use it in cmd2sys
bugfix: lib/sh/util.sh: .rel(): first use realpath() on BASH_SOURCE1 in case it's a symlink (as it is for bin/make)
lib/sh/util.sh: self_sys alias: use new sys_cmd() instead of `command -p` so that only the command path resolution is performed with a limited PATH, and the invoked command itself inherits the full PATH
lib/sh/util.sh: added sys_cmd(), which runs a system command and allows running a system command of the same name as the script
lib/sh/util.sh: added echo_builtin()
lib/sh/util.sh: command(): added nonrecursive=1 flag, which uses cmd2abs_path to run an external command nonrecursively
lib/sh/util.sh: added cmd2abs_path, which makes the command in $1 nonrecursive
bugfix: lib/sh/util.sh: PATH_rm(): also need to remove adjacent occurrences of the same path (or occurrences which become adjacent when other paths are removed), which :...: matching wasn't doing because the trailing : is consumed, preventing it from being matched at the beginning of the next path. since unlike filesystem paths with /, it is not necessary for a match to span multiple :-separated sections, we can just use new split() to split apart the PATH into an array of paths, filter each path, and join() them back together.
lib/sh/util.sh: added split()
lib/sh/util.sh: auto-echo common external commands: added `which`
lib/sh/util.sh: auto-echo common external commands: use simpler echo_run instead of command since logging handling is not needed
lib/sh/util.sh: added in_top_dir()
lib/sh/util.sh: added wildcard1 alias
lib/sh/util.sh: added echo1()
lib/sh/util.sh: command-specific alternate stdin/stdout/stderr: choice of 40/41/42: added mnemonic that 4 looks like A for Alternate
bugfix: lib/sh/util.sh: verbosity_compat(): always use default verbosity (`unset verbosity`) when verbosity == 1, regardless of whether the caller has set $verbosity to the special value "", because $verbosity is supposed to be an integer field and "" is not supported by most functions that use $verbosity. in cases where a util.sh script is invoked, it will set $verbosity back to the default value 1, so this will function as before for util.sh scripts and fix $verbosity for scripts that use a different verbosity system.
lib/sh/util.sh: echo_func(): check can_log at beginning of function, so that the resource-intensive func_loc (which calls `readlink -f`) does not need to be called if echo_cmd would not log anything at the current verbosity
lib/sh/util.sh: echo_func(): removed no longer used $minor flag. use `clog++... echo_func` instead.
lib/sh/util.sh: verbosity_compat(): don't make $verbosity a local var of this function, because then the changes will not be visible to the caller
lib/sh/util.sh: command(): command__exec(): use verbosity_compat to support commands that don't support verbosity=""
lib/sh/util.sh: added verbosity_compat(), for use with commands that don't support verbosity=""
bugfix: lib/sh/util.sh: self, self_sys aliases: need to remove any func_override suffix __* from the FUNCNAME
lib/sh/util.sh: added .rel()
lib/sh/util.sh: .(): put echo_func on its own line for clarity
lib/sh/util.sh: .(): added echo_func (2 log_levels up because it's internal)
lib/sh/util.sh: verbosity_min(): support value '', which sets verbosity=''
lib/sh/util.sh: run_args_cmd(): time the command so that the runtime of the outer runscript target (i.e. the command run from the shell) is printed at the end of the output, like in bin/make
lib/sh/util.sh: added mv2dir(), mv_glob which wrap mv
lib/sh/util.sh: added mkdir alias which adds -p to prevent errors if the dir already exists
lib/sh/util.sh: added wildcard alias, similar to make's $(wildcard) function
lib/sh/util.sh: added path_parents()
*{.sh,run}: in comments, use ${array[@]} instead of @array for clarity
lib/sh/util.sh: foreach_arg(): moved `local a` to same line as for loop that uses it
lib/sh/util.sh: foreach_arg(): echo_run the cmd at a log_level up so it isn't printed as if it were an external command (log_level 1)
bugfix: lib/sh/util.sh: set_fds(): localize $i so it doesn't overwrite any previous value
lib/sh/util.sh: added foreach_arg()
bugfix: lib/sh/util.sh: need to use `declare -p` instead of ${var+isset} because ${var+isset} returns not set for empty arrays
lib/sh/util.sh: added echo_vars() stub
lib/sh/util.sh: added echo_run() stub
lib/sh/util.sh: set_fds(): don't run (or echo) exec if no redirections are being made
bugfix: lib/sh/util.sh: added missing stub for indent alias (used by echo_func alias, which is a stub). without the stub, /usr/bin/indent would be used instead on Mac.
lib/sh/util.sh: support custom $base_dir, which will be run through realpath() to match $path ($PWD, which was used before, did not need to be realpath'd because it was already absolute)
lib/sh/util.sh: moved echo_func alias to stub because it must be embedded in its expanded alias form to work properly
lib/sh/util.sh: declare echo_func as a stub before it's defined, so that functions can use it even if they are defined before it (and its logging functionality will be enabled as soon as it's defined)
lib/sh/util.sh: rel_path(): don't log++ it, and instead only log++ applicable calls of it or its callers. this allows non-internal calls of rel_path() to be logged at the usual log_level.
lib/sh/util.sh: log+ aliases: added clog++/-- aliases for cmds, which don't include log_local. these are useful when you can't just use "log++" because you need the command following it to be alias-expanded.
lib/sh/util.sh: added bg_cmd() and helpers log_bg(), log_last_bg()
lib/sh/util.sh: command(): print the log_fd in effect in case the user changes it
lib/sh/util.sh: no_PATH_recursion(): also remove $top_symlink_dir_abs
lib/sh/util.sh: added $top_symlink_dir_abs
lib/sh/util.sh: $top_dir_orig: renamed to $top_symlink_dir since this reflects better what the dir actually represents, and when it differs from $top_dir
lib/sh/util.sh: added $is_outermost, which stores whether the util.sh env has not yet set up
lib/sh/util.sh: echo_redirs_cmd(): added $cmd_name_log_inc kw param to allow echoing the command name at a different log_level than the command output
lib/sh/util.sh: filter_fd: alias-expand filter_cmd
lib/sh/util.sh: added no_PATH_recursion(), which allows running a system command of the same name as the script
lib/sh/util.sh: added PATH_rm(), which removes components from the PATH
lib/sh/util.sh: added $top_dir_abs, $top_dir_orig