Skip to content

Option -f does not work with files in /tmp #26

@aleb

Description

@aleb

In this Travis CI build you can see how ctags is executed three times:
https://travis-ci.org/daedaleanai/reqtraq/builds/625770261?utm_source=github_status&utm_medium=notification

First call succeeds and /home/travis/x123y456 is created fine, but if the output file is set to /tmp/x123y456 the file is not created and universal-ctags does not report any error.

$ ls -al /tmp
total 68
drwxrwxrwt 14 root   root   4096 Dec 16 16:44 .
drwxr-xr-x 24 root   root   4096 Dec 16 16:43 ..
drwxrwxrwt  2 root   root   4096 Dec 16 16:42 .font-unix
drwxrwxr-x  2 travis travis 4096 Dec 16 16:44 gimme
-rw-rw-r--  1 travis travis   71 Dec 16 16:43 hosts_127_0_0_1
-rw-rw-r--  1 travis travis  265 Dec 16 16:43 hosts_sans_127_0_0_1
-rw-rw-r--  1 travis travis  356 Dec 16 16:43 hosts.tmp
drwxrwxrwt  2 root   root   4096 Dec 16 16:42 .ICE-unix
drwx------  3 root   root   4096 Dec 16 16:43 systemd-private-c54bbfa7db224153b3e1dd926acbddbc-chrony.service-1cssYY
drwx------  3 root   root   4096 Dec 16 16:42 systemd-private-c54bbfa7db224153b3e1dd926acbddbc-haveged.service-lJlyEb
drwx------  3 root   root   4096 Dec 16 16:42 systemd-private-c54bbfa7db224153b3e1dd926acbddbc-systemd-resolved.service-PI4I4x
drwxrwxrwt  2 root   root   4096 Dec 16 16:42 .Test-unix
drwx------  2 travis travis 4096 Dec 16 16:44 tmp.JTfhBtZ43L
drwxrwxr-x  3 travis travis 4096 Dec 16 16:43 travis
drwxrwxr-x  3 travis travis 4096 Dec 16 16:43 v8-compile-cache-2000
drwxrwxrwt  2 root   root   4096 Dec 16 16:42 .X11-unix
drwxrwxrwt  2 root   root   4096 Dec 16 16:42 .XIM-unix
The command "ls -al /tmp" exited with 0.

$ universal-ctags --kinds-C++=f --kinds-GO=f --fields=n --recurse --sort=no -f /home/travis/x123y456 /home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
The command "universal-ctags --kinds-C++=f --kinds-GO=f --fields=n --recurse --sort=no -f /home/travis/x123y456 /home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1" exited with 0.

$ cat /home/travis/x123y456
!_TAG_FILE_FORMAT	2	/extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED	0	/0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR	Universal Ctags Team	//
!_TAG_PROGRAM_NAME	Universal Ctags	/Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL	https://ctags.io/	/official site/
!_TAG_PROGRAM_VERSION	0.0.0	/9fcdb065/
!_TAG_OUTPUT_MODE	u-ctags	/u-ctags or e-ctags/
!_TAG_OUTPUT_FILESEP	slash	/slash or backslash/
getNumberOfSegments	/home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1/a.c	/^uint8_t System::getNumberOfSegments() {$/;"	line:14
getSegment	/home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1/a.c	/^const PcieSegment *System::getSegment(uint8_t i) {$/;"	line:20
enumerateObjects	/home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1/a.c	/^void enumerateObjects() {$/;"	line:30
The command "cat /home/travis/x123y456" exited with 0.

$ universal-ctags --kinds-C++=f --kinds-GO=f --fields=n --recurse --sort=no -f /tmp/x123y456 /home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
The command "universal-ctags --kinds-C++=f --kinds-GO=f --fields=n --recurse --sort=no -f /tmp/x123y456 /home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1" exited with 0.

$ cat /tmp/x123y456
cat: /tmp/x123y456: No such file or directory
The command "cat /tmp/x123y456" exited with 1.

As you can see, the /tmp folder is writable, so the write error should be reported accordingly. If the stdout is redirected to the file it works fine:

$ universal-ctags --kinds-C++=f --kinds-GO=f --fields=n --recurse --sort=no -f - /home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1 > /tmp/x123y456
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
The command "universal-ctags --kinds-C++=f --kinds-GO=f --fields=n --recurse --sort=no -f - /home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1 > /tmp/x123y456" exited with 0.

$ cat /tmp/x123y456
getNumberOfSegments	/home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1/a.c	/^uint8_t System::getNumberOfSegments() {$/;"	line:14
getSegment	/home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1/a.c	/^const PcieSegment *System::getSegment(uint8_t i) {$/;"	line:20
enumerateObjects	/home/travis/gopath/src/github.com/daedaleanai/reqtraq/testdata/cproject1/a.c	/^void enumerateObjects() {$/;"	line:30

(Any reason against working around the issue by using the stdout?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions