avoid collisions with common /usr/bin/ commands

rename head, tail, zip to lhead, ltail, and lzip to avoid collisions with command unix commands
This commit is contained in:
tpoindex 2019-09-11 23:53:56 -06:00 committed by Sławomir Śledź
parent 44dbdd3fbc
commit 1b234ff597
3 changed files with 18 additions and 18 deletions

View file

@ -8,11 +8,11 @@ take() {
command head -n ${1}
}
tail() {
ltail() {
drop 1
}
head() {
lhead() {
take 1
}
@ -316,7 +316,7 @@ ntupr() {
ntupx 1- "$@" | last
}
zip() {
lzip() {
local list=$*
cat - | while read x; do
y=$(list $list | take 1)

View file

@ -1,16 +1,16 @@
#! /bin/bash
testHeadFromList() {
assertEquals 1 $(list {1..10} | head)
assertEquals 5 $(list 5 6 7 | head)
testLHeadFromList() {
assertEquals 1 $(list {1..10} | lhead)
assertEquals 5 $(list 5 6 7 | lhead)
}
testHeadFromOneElementList() {
assertEquals 1 $(list 1 | head)
testLHeadFromOneElementList() {
assertEquals 1 $(list 1 | lhead)
}
testHeadFromEmptyList() {
assertEquals "" "$(list | head)"
testLHeadFromEmptyList() {
assertEquals "" "$(list | lhead)"
}
. ./shunit2-init.sh
. ./shunit2-init.sh

View file

@ -1,15 +1,15 @@
#! /bin/bash
testTailFrom10() {
assertEquals "2 3 4 5 6 7 8 9 10" "$(list {1..10} | tail | unlist)"
testLTailFrom10() {
assertEquals "2 3 4 5 6 7 8 9 10" "$(list {1..10} | ltail | unlist)"
}
testTailFromOneElementList() {
assertEquals "" "$(list 1 | tail)"
testLTailFromOneElementList() {
assertEquals "" "$(list 1 | ltail)"
}
testTailFromEmptyList() {
assertEquals "" "$(list | tail)"
testLTailFromEmptyList() {
assertEquals "" "$(list | ltail)"
}
. ./shunit2-init.sh
. ./shunit2-init.sh