mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
tests: correct usage of pipe
This is somewhat tricky - for test suite we keep using 'set -e -o pipefail' - the effect here is - we get error report from any 'failing' command in whole pipeline - thus when something like this: 'lvs | head -1' is used - and 'head' finishes before lead 'lvs' is done - it recieves SIGPIPE and exits with error, and somewhat misleading gets occasionally reported depending of speed of commands. For this case we have to avoid using standard pipes and rather switch to using streamed results with temporary output file. This is all nicely handled with bash feature '< <()'. For more info: https://stackoverflow.com/questions/41516177/bash-zcat-head-causes-pipefail
This commit is contained in:
parent
e7f1329cae
commit
8e5305f630
@ -47,7 +47,7 @@ lv_field() {
|
||||
|
||||
lv_first_seg_field() {
|
||||
local r
|
||||
r=$(lvs --config 'log{prefix=""}' --noheadings -o "$2" "${@:3}" "$1" | head -1)
|
||||
r=$(head -1 < <(lvs --config 'log{prefix=""}' --unbuffered --noheadings -o "$2" "${@:3}" "$1"))
|
||||
trim_ "$r"
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ lv_field_lv_() {
|
||||
lv_tree_devices_() {
|
||||
local lv="$1/$2"
|
||||
local type
|
||||
type=$(lv_field "$lv" segtype -a --unbuffered | head -n 1)
|
||||
type=$(lv_first_seg_field "$lv" segtype -a)
|
||||
#local orig
|
||||
#orig=$(lv_field_lv_ "$lv" origin)
|
||||
# FIXME: should we count in also origins ?
|
||||
|
Loading…
Reference in New Issue
Block a user