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:
parent
44dbdd3fbc
commit
1b234ff597
3 changed files with 18 additions and 18 deletions
|
@ -8,11 +8,11 @@ take() {
|
||||||
command head -n ${1}
|
command head -n ${1}
|
||||||
}
|
}
|
||||||
|
|
||||||
tail() {
|
ltail() {
|
||||||
drop 1
|
drop 1
|
||||||
}
|
}
|
||||||
|
|
||||||
head() {
|
lhead() {
|
||||||
take 1
|
take 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ ntupr() {
|
||||||
ntupx 1- "$@" | last
|
ntupx 1- "$@" | last
|
||||||
}
|
}
|
||||||
|
|
||||||
zip() {
|
lzip() {
|
||||||
local list=$*
|
local list=$*
|
||||||
cat - | while read x; do
|
cat - | while read x; do
|
||||||
y=$(list $list | take 1)
|
y=$(list $list | take 1)
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
testHeadFromList() {
|
testLHeadFromList() {
|
||||||
assertEquals 1 $(list {1..10} | head)
|
assertEquals 1 $(list {1..10} | lhead)
|
||||||
assertEquals 5 $(list 5 6 7 | head)
|
assertEquals 5 $(list 5 6 7 | lhead)
|
||||||
}
|
}
|
||||||
|
|
||||||
testHeadFromOneElementList() {
|
testLHeadFromOneElementList() {
|
||||||
assertEquals 1 $(list 1 | head)
|
assertEquals 1 $(list 1 | lhead)
|
||||||
}
|
}
|
||||||
|
|
||||||
testHeadFromEmptyList() {
|
testLHeadFromEmptyList() {
|
||||||
assertEquals "" "$(list | head)"
|
assertEquals "" "$(list | lhead)"
|
||||||
}
|
}
|
||||||
|
|
||||||
. ./shunit2-init.sh
|
. ./shunit2-init.sh
|
|
@ -1,15 +1,15 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
testTailFrom10() {
|
testLTailFrom10() {
|
||||||
assertEquals "2 3 4 5 6 7 8 9 10" "$(list {1..10} | tail | unlist)"
|
assertEquals "2 3 4 5 6 7 8 9 10" "$(list {1..10} | ltail | unlist)"
|
||||||
}
|
}
|
||||||
|
|
||||||
testTailFromOneElementList() {
|
testLTailFromOneElementList() {
|
||||||
assertEquals "" "$(list 1 | tail)"
|
assertEquals "" "$(list 1 | ltail)"
|
||||||
}
|
}
|
||||||
|
|
||||||
testTailFromEmptyList() {
|
testLTailFromEmptyList() {
|
||||||
assertEquals "" "$(list | tail)"
|
assertEquals "" "$(list | ltail)"
|
||||||
}
|
}
|
||||||
|
|
||||||
. ./shunit2-init.sh
|
. ./shunit2-init.sh
|
Loading…
Reference in a new issue