summaryrefslogtreecommitdiff
path: root/scripts/library
Commit message (Collapse)AuthorAge
* Fix spelling errors using 'codespell' toolAnatol Pomozov2013-04-18
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* contrib: Make pacdiff colors the same as makepkgWilliam Giokas2013-03-08
| | | | | | | Added an `ask` message function that emulates pacman's appearance. Signed-off-by: William Giokas <1007380@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* scripts: Add color to library/output_format.shWilliam Giokas2013-03-08
| | | | | | | | | | | Use the same colors as makepkg in messages. Add in the 'plain' function as well. To use the colors, you need to include the term_colors.sh file, or add definitions for the colors explicitly. Signed-off-by: William Giokas <1007380@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
* parseopts: remove superfluous continue/shift statementsDave Reisner2013-01-03
| | | | | | | | | | | | | | | | | | Fun fact about bash: the below is valid and will only ever print 'a'! fn() { continue 2 } for x in {1..5}; do for y in {a..e}; do echo "$y" fn done done Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
* paccache: adopt size_to_humanDave Reisner2012-06-25
| | | | Signed-off-by: Dave Reisner <dreisner@archlinux.org>
* scripts/library: add size_to_humanDave Reisner2012-06-25
| | | | | | | | | | | This function is the reverse of human_to_size, and converts integer byte sizes to human readable SI prefixed values. A logical extension of this might be to mimic the formatter that pacman uses and allow a second argument to be passed in which can coerce the size, rather than reducing until the unit count is below 1024. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
* scripts/library: add human_to_sizeDave Reisner2012-06-25
| | | | | | | | This is a bash wrapper around an awk function that parses human readable sizes and returns their representative values in bytes, as a string. A small test harness is added to validate the functionality. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
* scripts/library: remove parse_optionsDave Reisner2012-04-24
| | | | | | | This is retired, as the two consumers of this function are now using the new parseopts instead. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
* scripts/library: introduce parseoptsDave Reisner2012-04-24
| | | | | | | | | | | | | | | | | | This will replace our current options parser used in pacman-key, makepkg, and ideally elsewhere. It follows heuristics closer to that of GNU getopt long (and thus pacman itself), with the exception that it does not allow for options with optional arguments. Due to the way this parser will be used, this sort of functionality will not be needed. Instead of relying on eval+set, options are normalized into an array, OPTRET, which callers should expect to be populated after returning from parseopts. This avoids problems with quotes and spaces in arguments, assuming that the user quotes properly when passing into the application. A new test harness for parseopts is added in test/scripts. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
* Revert "parseopts: normalize options into an array"Dave Reisner2012-04-07
| | | | | | | | | | | | This was really only half a fix for FS#28445, as it still doesn't correctly handle the case of filenames with spaces. In the short term, there is no obvious fix for this. In the long term, I believe the correct decision is to rewrite the options parser to be more in line with GNU getopt_long. This reverts commits: ca4142714137b16feabac09c4cda86b0a75036f8. 969dcddbdf9d5dbd91aa414cdd193f3fb26b644b.
* parse_options: initialize unused_options as arrayDave Reisner2012-04-07
| | | | | | | | | | | Since we treat this as an array, we need to initialize it as one. This avoids addition of an empty element to the option string when we set the option array from the calling program, e.g. +/usr/bin/makepkg[2033]: set -- -i --pkg vim -- '' Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* parseopts: normalize options into an arrayDave Reisner2012-02-16
| | | | | | | | | | Modify parse_options logic to fill an array instead of printing parsed options. Avoid eval like the plague. Because it is the plague. Fixes bugs such as FS#28445. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* parse_options: accept multiple argumentsAllan McRae2011-07-05
| | | | | | | | | | | | | | | | Allow command-line options to accept multiple arguments without additional quoting by taking the list of arguments until one starting with a "-" is reached. The only current use of this is the --pkg option in makepkg. This allows (e.g.) makepkg --pkg foo bar and packages "foo" and "bar" will be built. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* parse_options: implement optional argumentsAllan McRae2011-07-05
| | | | | | | | This allows options specified with a trailing "::" to optionally take arguments. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* parse_options: add missing newlinesAllan McRae2011-07-05
| | | | | Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* parse-options: simplify unused-arg & parameter printingDave Reisner2011-06-24
| | | | Signed-off-by: Dave Reisner <d@falconindy.com>
* parse_options: adjust error messagesAllan McRae2011-06-15
| | | | | | | | Provide consistent error messages for unknown long and short options. Also get full string translation for the messages. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* scripts/library: add README fileAllan McRae2011-06-15
| | | | | | | | Add a README file to briefly document the code snippets in the scripts library folder. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* scripts: refactor output formatting functionsAllan McRae2011-06-15
| | | | | | | | | Move the common output formatting functions into a separate library file and import that into each script. makepkg is excluded due to its additional color formatting. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* makepkg: move option parsing code to separate fileAllan McRae2011-06-15
This move the getopt replacement function parse_options out of makepkg.sh.in and into a separate file. The code is inserted into the relevant place in makepkg using m4. This will allow the reuse of the option parsing code in other scripts (i.e. pacman-key) while avoiding code duplication. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>