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
7b6531a74e
commit
1ead6d0b87
3 changed files with 18 additions and 18 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue