Enhance support for write commnet in plugins.txt

- add ability to write comment in plugins.txt
- remove leading spaces/tabs
- remove trailing spaces/tabs
- protect against empty lines

Enhanced #505

Signed-off-by: guessi <guessi@gmail.com>
This commit is contained in:
guessi 2017-12-09 17:33:14 +08:00
parent ca17603a0f
commit d85be653b5
2 changed files with 27 additions and 5 deletions

View File

@ -191,7 +191,13 @@ main() {
# Read plugins from stdin or from the command line arguments
if [[ ($# -eq 0) ]]; then
while read -r line || [ "$line" != "" ]; do
plugins+=("${line}")
# Remove leading/trailing spaces, comments, and empty lines
plugin=$(echo "${line}" | sed -e 's/^[ \t]*//g' -e 's/[ \t]*$//g' -e 's/[ \t]*#.*$//g' -e '/^[ \t]*$/d')
# Avoid adding empty plugin into array
if [ ${#plugin} -ne 0 ]; then
plugins+=("${plugin}")
fi
done
else
plugins=("$@")

View File

@ -1,5 +1,21 @@
# comment line should be skipped
# simple case
ant:1.3
maven-plugin:2.7.1
mesos:0.13.0
git:latest
filesystem_scm:experimental
# trailing spaces
maven-plugin:2.7.1
# leading spaces
mesos:0.13.0
# leading spaces, and trailing spaces
git:latest
# with comments at the end
filesystem_scm:experimental # comment at the end
# empty line
#
# empty line