Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .fpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-s dir
-f
--name rebash
--license WTFPL
--version 0.0.8
--architecture all
--depends bash
--depends sed
--depends grep
--provides rebash
--description 'bash/shell library/framework'
--url 'https://github.com/jandob/rebash'
--maintainer 'Janosch Dobler <janosch.dobler@gmx.de>'
--after-install 'after-install.sh'
--after-remove 'after-remove.sh'

rebash.sh=/usr/bin/rebash
src/=/usr/lib/rebash/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ sudo: required
dist: trusty
language: bash
script:
- bash doc_test.sh
- bash rebash.sh
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from alpine:latest

COPY dist/rebash-0.0.8-any.apk /tmp/

RUN apk add --allow-untrusted /tmp/rebash-0.0.8-any.apk

ENTRYPOINT [ "/bin/bash", "-c" ]

CMD [ "exec bash --init-file <(echo '. /usr/lib/rebash.sh') -i" ]
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ifndef PREFIX
override PREFIX=/usr/local
endif

VERSION=0.0.8

.PHONY: test install package

test:
bash rebash.sh --side-by-side --no-check-undocumented -v

install:
install -b rebash.sh $(PREFIX)/bin/rebash
mkdir -p $(PREFIX)/lib/rebash
sudo cp -f src/* $(PREFIX)/lib/rebash/
bash after-install.sh

package:
mkdir -p ./dist
# fpm -t pacman -p dist/rebash-$(VERSION)-any.pkg bsdtar required?
fpm -t deb -p dist/rebash-$(VERSION)-any.deb
fpm -t rpm -p dist/rebash-$(VERSION)-any.rpm
fpm -t apk --depends coreutils -p dist/rebash-$(VERSION)-any.apk

docker:
make package
docker build -t jandob/rebash:0.0.8 .
docker push jandob/rebash:0.0.8 && \
docker tag jandob/rebash:0.0.8 jandob/rebash:latest && \
docker push jandob/rebash:latest
4 changes: 2 additions & 2 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ package() {
mkdir -p "${pkgdir}/usr/bin"
rm -r "${srcdir}/rebash/images"
cp -r "${srcdir}/rebash/" "${pkgdir}/usr/lib/"
ln -sT /usr/lib/rebash/doc_test.sh "${pkgdir}/usr/bin/rebash-doc-test"
ln -sT /usr/lib/rebash/documentation.sh "${pkgdir}/usr/bin/rebash-documentation"
ln -sT /usr/lib/rebash/src/doc_test.sh "${pkgdir}/usr/bin/rebash-doc-test"
ln -sT /usr/lib/rebash/src/documentation.sh "${pkgdir}/usr/bin/rebash-documentation"
}
5 changes: 5 additions & 0 deletions after-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

echo "export REBASH_HOME=/usr/lib/rebash" | tee /etc/.rebash
chmod 0755 /etc/.rebash
ln -s /usr/bin/rebash /usr/lib/rebash.sh
4 changes: 4 additions & 0 deletions after-remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

rm -rf /etc/.rebash
rm -f /usr/lib/rebash.sh
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "rebash",
"version": "0.0.8",
"description": "bash/shell library/framework",
"install": "make install",
"scripts": [ "rebash.sh" ],
"files": [
"src/arguments.sh",
"src/array.sh",
"src/btrfs.sh",
"src/change_root.sh",
"src/core.sh",
"src/dictionary.sh",
"src/doc_test.sh",
"src/documentation.sh",
"src/exceptions.sh",
"src/logging.sh",
"src/time.sh",
"src/ui.sh",
"src/utils.sh"
]
}
22 changes: 22 additions & 0 deletions rebash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

VERSION=0.0.8

if [ -f $HOME/.rebash ]; then
source $HOME/.rebash
else
if [ -f /etc/.rebash ]; then
source /etc/.rebash
fi
fi

if [ -z "$REBASH_HOME" ]; then
export REBASH_HOME=`dirname ${BASH_SOURCE[0]}`/src
fi

if [[ ${BASH_SOURCE[0]} != $0 ]]; then
source $REBASH_HOME/core.sh
else
$REBASH_HOME/doc_test.sh "${@}"
exit $?
fi
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions core.sh → src/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -292,20 +292,20 @@ core_import() {
>>> (
>>> core.import logging
>>> logging_set_level warn
>>> core.import test/mockup_module-b.sh false
>>> core.import ../test/mockup_module-b.sh false
>>> )
+doc_test_contains
imported module c
module "mockup_module_c" defines unprefixed name: "foo123"
imported module b

Modules should be imported only once.
>>> (core.import test/mockup_module_a.sh && \
>>> core.import test/mockup_module_a.sh)
>>> (core.import ../test/mockup_module_a.sh && \
>>> core.import ../test/mockup_module_a.sh)
imported module a

>>> (
>>> core.import test/mockup_module_a.sh false
>>> core.import ../test/mockup_module_a.sh false
>>> echo $core_declared_functions_after_import
>>> )
imported module a
Expand All @@ -314,7 +314,7 @@ core_import() {
>>> (
>>> core.import logging
>>> logging_set_level warn
>>> core.import test/mockup_module_c.sh false
>>> core.import ../test/mockup_module_c.sh false
>>> echo $core_declared_functions_after_import
>>> )
+doc_test_contains
Expand Down
4 changes: 2 additions & 2 deletions dictionary.sh → src/dictionary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ dictionary_get_keys() {

>>> dictionary_set map foo "a b c" bar 5
>>> dictionary_get_keys map
bar
foo
bar

Iterate keys:
>>> dictionary_set map foo "a b c" bar 5
>>> local key
>>> for key in $(dictionary_get_keys map); do
>>> echo "$key": "$(dictionary_get map "$key")"
>>> done
bar: 5
foo: a b c
bar: 5

>>> dictionary__bash_version_test=true
>>> dictionary_set map foo "a b c" bar 5
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/mockup_module-b.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# shellcheck source=./core.sh
source "$(dirname "${BASH_SOURCE[0]}")/../core.sh"
source "$(dirname "${BASH_SOURCE[0]}")/../src/core.sh"
core.import logging
core.import mockup_module_c.sh
echo imported module b
2 changes: 1 addition & 1 deletion test/mockup_module_a.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# shellcheck source=../core.sh
source "$(dirname "${BASH_SOURCE[0]}")/../core.sh"
source "$(dirname "${BASH_SOURCE[0]}")/../src/core.sh"
mockup_module_a_foo() {
echo "a"
}
Expand Down
2 changes: 1 addition & 1 deletion test/mockup_module_c.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# shellcheck source=./core.sh
source "$(dirname "${BASH_SOURCE[0]}")/../core.sh"
source "$(dirname "${BASH_SOURCE[0]}")/../src/core.sh"
core.import logging
core.import mockup_module-b.sh
foo123() {
Expand Down