Skip to content

Commit

Permalink
v4.1.0
Browse files Browse the repository at this point in the history
  - switched to semantic versioning, with new var `CGIBASHOPTS_RELEASE`
  - new -d option to specify the temporary directory (suggestion of "Aufschlauer")
  - move to GitHub: moved most files out of the main view, in tests/, tewiba upgraded to 1.5.0, code cleanup up to pass shellcheck
  • Loading branch information
ColasNahaboo committed Dec 23, 2021
1 parent 7185cd1 commit 24eed39
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ E.g: `source /usr/local/bin/cgibashopts` or
- if you do not expect to have files uploaded, you can use the -n option (see below)
- **Command line options:**
- **-n** can be given to ignore and discard any requests to upload files. This is recommended if you do not expect files to be uploaded, as it can save some computing load if some attacker try to upload fake files, but not mandatory. It also does not defines the variable `$CGIBASHOPTS_DIR` nor the function `cgibashopts_clean`, and do not use trap. **Note:** This is only available in versions 3 and above. Example of use : `. cgibashopts -n`
- **-d directory** specifies where cgibashoptions will manage its temporary files in case of file uploads. It defaults to `/tmp`. cgibashoptions will create in it a `cgibashopts-files.$$` subdirectory (where `$$` is the bash process number, unique per instance), shown in the `$CGIBASHOPTS_DIR` variable.
- The variable `CGIBASHOPTS_RELEASE` holds the release version, uses [semantic versioning](https://semver.org/) (e.g. 4.0.1, 4.4.3) of the cgibashopts libray used, versions being listed at the end of this page in *History of changes*...
- The variable `CGIBASHOPTS_VERSION` holds the major version number (the first integer of `CGIBASHOPTS_RELEASE` above, for backwards compatibility.
- Misc goodies:
Expand All @@ -64,7 +65,10 @@ Feel welcome to copy and enhance this project, as well as providing bug reports,
- Or just email me: [email protected]

## History of changes
- 2020-04-20 non-code reorg: moved most files out of the main view, in tests/, tewiba upgraded to 1.5.0-pre.3
- 2021-12-23 v4.1.0
- switched to semantic versioning, with new var `CGIBASHOPTS_RELEASE`
- new -d option to specify the temporary directory (suggestion of "Aufschlauer")
- move to GitHub: moved most files out of the main view, in tests/, tewiba upgraded to 1.5.0, code cleanup up to pass shellcheck
- 2020-04-16 Version 4: urlencode goodie function added
- 2020-04-04 Some cosmetic changes in this doc and the tests (test-suite dir renamed as tests), but no changes to cgibashopts code itself, so no version number increase.
- 2020-03-27 Version 3: -n option added to disable file uploads
Expand Down
21 changes: 18 additions & 3 deletions cgibashopts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,30 @@
# See https://github.com/ColasNahaboo/cgibashopts
# Uses the CGI env variables REQUEST_METHOD CONTENT_TYPE QUERY_STRING

export CGIBASHOPTS_RELEASE=4.0.1
export CGIBASHOPTS_RELEASE=4.1.0
export CGIBASHOPTS_VERSION="${CGIBASHOPTS_RELEASE%%.*}"
cr=$'\r'
nl=$'\n'
export FORMS=
export FORMFILES=
export FORMQUERY=
if [ x"$1" != x-n ]; then
export CGIBASHOPTS_DIR=/tmp/cgibashopts-files.$$

# parse options
uploads=true
tmpfs=/tmp
OPTIONS='nd:'
OPTIND=1
while getopts "${OPTIONS}" _o;do
case "$_o" in
n) uploads=false;;
d) tmpfs="$OPTARG";;
*) echo "unknown option: $_o"; exit 1;;
esac
done
shift $((OPTIND-1))

if "$uploads"; then
export CGIBASHOPTS_DIR="$tmpfs/cgibashopts-files.$$"
CGIBASHOPTS_TMP="$CGIBASHOPTS_DIR.tmp"
cgibashopts_clean() {
[ -n "$CGIBASHOPTS_DIR" ] && [ -d "$CGIBASHOPTS_DIR" ] && rm -rf "$CGIBASHOPTS_DIR"
Expand Down

0 comments on commit 24eed39

Please sign in to comment.