drive icon indicating copy to clipboard operation
drive copied to clipboard

Impossible to save more than 1 line of "drive push" output to file on Linux

Open jean-christophe-manciot opened this issue 8 years ago • 4 comments

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?

jean-christophe-manciot avatar Dec 25 '16 16:12 jean-christophe-manciot

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

jean-christophe-manciot avatar Dec 27 '16 16:12 jean-christophe-manciot

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.

odeke-em avatar Jan 22 '17 04:01 odeke-em

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

tanius avatar Feb 01 '19 14:02 tanius

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

scotte avatar Jan 19 '22 16:01 scotte