Permalink
Commits on Sep 16, 2016
Commits on Sep 11, 2016
  1. Fix missing quote in example

    committed Sep 11, 2016
Commits on May 1, 2015
Commits on Apr 2, 2015
  1. Append `-frame` in xwininfo_get_window_by_ref()

    This change was intended to enable including borders of windows selected
    by window ID. Unfortunately, the `-frame` option of xwininfo is only
    effective when manually selecting windows, and is ignored when used with
    `-id`. Nevertheless, I'm making this change.
    committed Apr 2, 2015
Commits on Sep 13, 2014
  1. Omit `in "$@"` - redundant

    committed Sep 13, 2014
Commits on Sep 8, 2014
  1. Remove erroneous check

    Should have checked whether $cmd was in sub_cmdfuncs; but let's not care
    so much for stupidity.
    committed Sep 8, 2014
Commits on Sep 7, 2014
  1. Remove redundant check

    committed Sep 7, 2014
  2. Add COPYING file

    committed Sep 7, 2014
  3. Long variables suck

    committed Sep 7, 2014
Commits on Sep 6, 2014
  1. Change syntax prototype

    committed Sep 6, 2014
Commits on Sep 3, 2014
  1. Release 2.4.0

    Note to users:
    
    If you have defined your own sub-commands, you will need to change the
    region geometry variable names. Refer the the shipped subcmd script.
    committed Sep 3, 2014
  2. Give sed some love

    committed Sep 3, 2014
Commits on Sep 2, 2014
  1. Add two more points on call by reference functions

    Rename: .md -> .markdown (filetype.vim: *.md is taken by "Modula 2")
    committed Sep 2, 2014
Commits on Sep 1, 2014
  1. Document coding style and conventions

    Add HACKING file for reference.
    Apply coding style to existing code.
    Rethink variable naming conventions. (noref_ no more)
    committed Sep 1, 2014
Commits on Aug 31, 2014
  1. nameref variables considered buggy

    Assignment to a subscripted array variable behaves differently for
    nameref vs `printf -v`, as shown below.
    
    Assignment via nameref variable:
    
        declare -a arr=()
        func() {
          local -n ref=$1
          ref='nameref'
        }
        func 'arr[0]'
        declare -p 'arr[0]' arr
    
        --- output ---
        declare -- arr[0]="nameref"
        declare -a arr='()'
    
    Assignment via `printf -v`:
    
        declare -a arr=()
        func() {
          printf -v "$1" 'printf -v'
        }
        func 'arr[0]'
        declare -p 'arr[0]' arr
    
        --- output ---
        ap.sh: line 6: declare: arr[0]: not found
        declare -a arr='([0]="printf -v")'
    
    For reference, the "normal" behavior:
    
        declare -a arr=()
        arr[0]='normal'
        declare -p 'arr[0]' arr
    
        --- output ---
        no.sh: line 3: declare: arr[0]: not found
        declare -a arr='([0]="normal")'
    
    The above suggests it's the `printf -v` behavior is correct, while the
    nameref assignment isn't. Likely a bash bug.
    committed Aug 31, 2014
  2. local variables considered harmful

    Consider the following function:
    
        func() {
          local -n ref_var=$1
          local foo="Oops"
          ref_var="Gotcha"
        }
        foo="Fail"
        func foo
        echo $foo
    
        => Fail
    
    When nameref variables are involved, local variables can introduce
    unexpected and non-obvious bugs like the above. The biggest problem is
    that the caller cannot predict -- and in principle, should never have to
    care about -- what local variables the called function defines.
    
    Therefore, strictly speaking, any function that uses nameref variables
    to assign external variables must not set any local variables,
    *including* nameref variables -- a perfect paradox.
    
    As such, artificial variable naming conventions have to be established.
    But before we think of that, consider the following principles:
    
     - Always prefer positional parameters over local variables.
     - Always prefer bash ALL_CAPS variables over local variables.
     - Define as few local variables as possible.
     - Use sub-shells, sub-functions, or external programs to reduce
       namespace pollution.
    
    These are good practices when writing functions that use nameref
    variables. The absolutely necessary naming conventions are:
    
     - Prefix with `ref_` if and only if it's a nameref variables.
     - Prefix with `noref_` if and only if it's a non-nameref variable that
       must never be referenced by a nameref variable. Non-nameref local
       variables defined inside the same function as a nameref variable are
       such variables.
    
    The noteworthy patterns and changes in this commit are:
    
    1. In an effort to reduce local variables, the idiom
    
           IFS=' ' read -r a b c <<< "$foo"
    
       is replaced with
    
           IFS=' '; set -- $foo
    
       because positional parameters are the best.
    
    2. Similarly, the idiom
    
           while IFS=' ' read -r line; do ... $line ...; done
    
       is replaced with
    
           while IFS=' ' read -r REPLY; do ... $REPLY ...; done
    
       because bash ALL_CAPS variables are the second best.
    
    3. The `IFS='...'; set -- ...` trick is applied in some more places,
       and `"$*"` turns out to be really handy. Positional parameters rock.
    
    4. The use of `awk` in xwininfo_get_window_by_ref().
    
    5. Several global variables are renamed as follows:
    
           rootw -> root_w
           rooth -> root_h
           w     -> rect_w
           h     -> rect_h
           _x    -> rect_x
           _y    -> rect_y
           x_    -> rect_X
           y_    -> rect_Y
    committed Aug 30, 2014
Commits on Aug 30, 2014
  1. Release 2.3.0 "Elaborate"

    committed Aug 30, 2014
  2. 'each' now supports format strings %i, %n, %t

    Try: ffcast -ws each echo %%%%%n-%t_%i
    committed Aug 30, 2014
  3. Separate format string processor from mapping data

    Strip out the format string mapping data from the format string
    translator function, so we can re-use this worker function with other
    format string mapping rules.
    
    Note `eval` is used in substitute_format_strings() to evaluate variables
    at runtime. Keep this in mind when writing format string mapping rules.
    committed Aug 30, 2014
  4. Refactor screen selection data structure

    Previously all selections are stripped to a "region", i.e. nothing more
    than an "offsets" value stored in the offsets_list array. There was no
    way of knowing where each set of offsets came from.
    
    This commit introduces several new data structures for preserving
    information of the origin of each selection, as well as the order in
    which the selections are made.
    The implementation is not pretty, mostly because bash lacks support for
    multi-dimensional arrays. But it's an improvement, nevertheless.
    
    The indexed array 'rects' stores varname of each selection, in the
    order they are made.
    
    The indexed array 'regions' stores offsets of rectangular region
    selections made by '-g' and '-s'.
    
    The associative array 'heads' stores offsets of selected Xinerama heads,
    with keys set to their head ID.
    
    The associative array 'windows' stores offsets of window selections made
    by '-#' and '-w', with keys set to their window ID.
    
    With these variables, the offsets_list array is redundant, but for now
    it's kept as is.
    
    Additionally, this commit also removes some duplication by processing
    the user selections live as the command line options are processed.
    This requires the root window size to be queried before options are
    processed, which means an error will be produced when ffcast is run
    without a $DISPLAY even if only -h is passed. To deal with this
    situation, make ffcast print the help message when this error happens.
    This also mandates that the '-q' and '-v' options be given before all
    other options, if they were to take global effect.
    committed Aug 29, 2014
Commits on Aug 28, 2014
  1. Release 2.2.1

    committed Aug 28, 2014
  2. external command: disallow shell builtins

    `command` only disables function lookup, but will happily run shell
    builtin commands. run_external_command() should not allow this.
    committed Aug 28, 2014