Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow packaging and distribution projects to easily configure data and binary directories #2

Closed
npryce opened this issue Feb 17, 2016 · 1 comment
Assignees

Comments

@npryce
Copy link
Owner

npryce commented Feb 17, 2016

See issue #1 for an example why this is needed.

Current thoughts:

Have a config.sh file that is sourced at the top of every script, and defines location of files.

E.g.:

#!/bin/bash
set -e
source $(dirname $0)/config.sh

...

And config.sh would define shell variables (not environment variables). The default would be:

adr_bin_dir="$(dirname $0)"
adr_template_dir="$adr_bin_dir"

Packaging scripts could replace the entire file. E.g.

adr_prefix=/usr/local
adr_bin_dir=$adr_prefix/bin
adr_template_dir=$adr_prefix/share/adr-tools/templates

Comments from packaging experts welcome.

@npryce
Copy link
Owner Author

npryce commented Feb 23, 2016

Implemented in master

@npryce npryce closed this as completed Feb 23, 2016
JonTheNiceGuy added a commit to JonTheNiceGuy/adr-tools that referenced this issue Jan 18, 2021
* Added a default value for adr_bin_dir
* Added relevant quotes and double quotes
* Moved compgen commands into a while/read line/do/done loop, and put match detection in there too.

```
In _adr_autocomplete line 2:
eval "$($(dirname $0)/adr-config)"
        ^-----------^ SC2046: Quote this to prevent word splitting.
                  ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
eval "$($(dirname "$0")/adr-config)"

In _adr_autocomplete line 4:
cmds=("$@")
^--^ SC2034: cmds appears unused. Verify use (or export if used externally).

In _adr_autocomplete line 5:
available_commands=$( $adr_bin_dir/_adr_commands | sort )
                      ^----------^ SC2154: adr_bin_dir is referenced but not assigned.
                      ^----------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
available_commands=$( "$adr_bin_dir"/_adr_commands | sort )

In _adr_autocomplete line 9:
  suggestions=($( compgen -W "${available_commands}" -- "$2" ))
               ^-- SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

In _adr_autocomplete line 10:
  if [ "$suggestions" != "$2" ]
        ^----------^ SC2128: Expanding an array without an index only gives the first element.

In _adr_autocomplete line 17:
subcmds_files=( $(compgen -G "$adr_bin_dir/_adr_$2_"'*' | sort ) )
                ^-- SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

In _adr_autocomplete line 22:
    basename $f | cut -c $(( ${npryce#2} + 7 ))-
             ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean:
    basename "$f" | cut -c $(( ${npryce#2} + 7 ))-

In _adr_autocomplete line 24:
  suggestions=($( compgen -W "${subcmds}" -- "$3" ))
               ^-- SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

In _adr_autocomplete line 25:
  if [ "$suggestions" != "$3" ]
        ^----------^ SC2128: Expanding an array without an index only gives the first element.

For more information:
  https://www.shellcheck.net/wiki/SC2034 -- cmds appears unused. Verify use (...
  https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...
  https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind...
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant