diff options
| author | Teddy Wing | 2018-04-19 20:51:42 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-04-19 20:51:42 +0200 | 
| commit | 01ffc7bedf4d07bb2817c999384db54dbb950aa7 (patch) | |
| tree | 23c832eecbab1bdfc4a2898c78d712f1659de8e4 | |
| parent | 9909a132d5a855f69501d2258e29d8dab80ab522 (diff) | |
| download | redprine-01ffc7bedf4d07bb2817c999384db54dbb950aa7.tar.bz2 | |
Set `$CACHE_FILE` in `preflight()`
We had initialised the `$CACHE_FILE` variable at the start of the script,
but because at that point `$GITHUB_OWNER_REPO` is empty, the cache file
just ends up getting called ".json".
In order to get the name we want, we need to wait until the
`$GITHUB_OWNER_REPO` variable is initialised by the command line
argument.
Initialise `$CACHE_FILE` in `preflight()` because it makes sense to put
it in that kind of setup function. Move `preflight()` after
`parse_arguments()` to ensure the program variables (including
`$GITHUB_OWNER_REPO`) are properly validated and initialised before
running setup code.
| -rwxr-xr-x | redprine | 6 | 
1 files changed, 4 insertions, 2 deletions
| @@ -17,7 +17,7 @@ REDMINE_JSON_PARAMS=''  XDG_DATA_HOME=${XDG_DATA_HOME:-"${HOME}/.local/share"}  REDPRINE_DATA_DIR=${REDPRINE_DATA_DIR:-"${XDG_DATA_HOME}/redprine"} -CACHE_FILE="${REDPRINE_DATA_DIR}/${GITHUB_OWNER_REPO/\//--}.json" +CACHE_FILE=''  CACHE_ONLY=0 @@ -207,6 +207,8 @@ function exit_with_error () {  function preflight () {  	mkdir -p "$REDPRINE_DATA_DIR" +	CACHE_FILE="${REDPRINE_DATA_DIR}/${GITHUB_OWNER_REPO/\//--}.json" +  	if [ ! -f "$CACHE_FILE" ]; then  		echo '[]' > "$CACHE_FILE"  	fi @@ -333,6 +335,6 @@ function parse_arguments () {  } -preflight  parse_arguments "$@" +preflight  main | 
