Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Problem. STDIN over | pipe, vs. Argument $1 confusion
- #This works (for one argument):
- bash$: dofunction2 'RaidZ-2TBx3/1'
- #This does not (for multiple lines):
- bash$: getfunction1 | dofunction2
- #Works:
- diffsnapshotadjacentpairsA() {
- getsnapshotadjacentpairs $1 | zfsdiffawksnapshot
- }
- #first export(including subfunctions):
- export -f diffsnapshotadjacentpairsA zfsdiffawksnapshot getsnapshotadjacentpairs getzfssnapshots
- #Argument:
- diffsnapshotadjacentpairsA 'RaidZ-2TBx3/1'
- #STDIN:
- getzfsdatasets | grep 'RaidZ-2TBx3/1' | xargs -I {} bash -c 'diffsnapshotadjacentpairsA "$1"' _ {}
- #Works:
- diffsnapshotadjacentpairsB() {
- if (($#)); then
- getsnapshotadjacentpairs $1 | zfsdiffawksnapshot
- else while read -r; do
- getsnapshotadjacentpairs $REPLY | zfsdiffawksnapshot
- done; fi
- }
- #Argument:
- diffsnapshotadjacentpairsB 'RaidZ-2TBx3/1'
- #STDIN:
- getzfsdatasets | grep 'RaidZ-2TBx3/1' | diffsnapshotadjacentpairsB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement