jdx / jdx/usage

`open: Permission denied` on Fedora (and Fish)

Open
#684 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1k
Forks
59
Avg merge
5h 58m
Merged PRs (30d)
362

Description

Adding the `usage g completion-init fish | source` when using Fish on Fedora results in this big list of errors when opening a new terminal:

```console
warning: An error occurred while redirecting file '/usr/bin/chfn'
open: Permission denied
warning: An error occurred while redirecting file '/usr/bin/chsh'
open: Permission denied
warning: An error occurred while redirecting file '/usr/bin/lockdev'
open: Permission denied
warning: An error occurred while redirecting file '/usr/bin/sudo'
open: Permission denied
warning: An error occurred while redirecting file '/usr/bin/sudoedit'
open: Permission denied
warning: An error occurred while redirecting file '/usr/bin/sudoreplay'
open: Permission denied
warning: An error occurred while redirecting file '/usr/bin/userhelper'
open: Permission denied
warning: An error occurred while redirecting file '/bin/chfn'
open: Permission denied
warning: An error occurred while redirecting file '/bin/chsh'
open: Permission denied
warning: An error occurred while redirecting file '/bin/lockdev'
open: Permission denied
warning: An error occurred while redirecting file '/bin/sudo'
open: Permission denied
warning: An error occurred while redirecting file '/bin/sudoedit'
open: Permission denied
warning: An error occurred while redirecting file '/bin/sudoreplay'
open: Permission denied
warning: An error occurred while redirecting file '/bin/userhelper'
open: Permission denied
kalle@mycomputer ~> _
```

Debugging this shows that apparently Fedora sets permission `4111` (only execute, not readable) on some binaries

```console
kalle@mycomputer ~> stat /bin/sudo
File: /bin/sudo
Size: 211088 Blocks: 416 IO Block: 4096 regular file
Device: 0,38 Inode: 307952 Links: 1
Access: (4111/---s--x--x) Uid: ( 0/ root) Gid: ( 0/ root)
Context: system_u:object_r:sudo_exec_t:s0
Access: 2026-06-15 22:19:35.578588221 +0200
Modify: 2026-04-14 02:00:00.000000000 +0200
Change: 2026-06-14 21:13:46.956617714 +0200
Birth: 2026-06-14 21:13:46.935617715 +0200
```

So in the completion script we need the `test` changed so it also checks for if the file is _readable_

https://github.com/jdx/usage/blob/d5734f0ba8b973935f8ab011c657d0e9d75f5e30/lib/src/complete/fish.rs#L115

```diff
- test -f $file -a -x $file; or continue
+ test -f $file -a -x $file -a -r $file; or continue
```

This probably also needs to be changed in the completion-init for the other shells too. For Bash I think it should be changed here:

https://github.com/jdx/usage/blob/d5734f0ba8b973935f8ab011c657d0e9d75f5e30/lib/src/complete/bash.rs#L135

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.