drive
drive copied to clipboard
Impossible to save more than 1 line of "drive push" output to file on Linux
I know that sounds strange but:
# drive push -verbose "$file" <<< $'Y' >> .output.log 2>&1
or
# echo 'Y' | drive push -verbose "$file" >> .output.log 2>&1
leads to the same 1 line result:
Resolving...
even though the command has been completed & the file has been completely pushed. Is there a trick to work around that issue to allow logging all output?
Ubuntu 16.10 4.8 drive version couldn't be any fresher:
drive version: 0.3.8.1
Commit Hash: 'fa3d326f72ae91399b2aa607c79293fb8a293b96'
Go Version: go1.7.1
OS: linux/amd64
BuildTime: 2016-12-24 06:22:04.78836032 +0100 CET
Aha, this is an interesting bug. From a quick guess, I think this bug manifests because of whether our output is a tty or not.
Will need some more investigation.
I am also having this bug, just that I experienced it with the copy
command:
drive copy file1 file2 2>&1 >log.txt
As a workaround, I use it with tee
like this:
drive copy file1 file2 2>&1 | tee log.txt
This happens because canPreview(), which is in the code path here, produces no output when stdout is not a TTY, regardless of the verbose flag being set - https://github.com/odeke-em/drive/blob/master/src/commands.go#L156
Not ideal behavior, in my opinion. Workaround is to use something like script to allocate a pseudo tty. This works for me:
script -qefc "drive push -verbose -no-prompt ." /dev/null