Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xdg-terminal-exec: Misc changes #46

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

fluvf
Copy link
Contributor

@fluvf fluvf commented Dec 17, 2023

See commit messages for details
These should again be the last changes I had queued up

Last two commits, b7f7682 and dfc44b1, are more opinionated
I'd like to see them merged, but feel free to cherry-pick them out if you so choose 👍

@Vladimir-csp
Copy link
Owner

I like everything except removing config validation errors.

@fluvf
Copy link
Contributor Author

fluvf commented Dec 18, 2023

After sleeping on it, I think I agree with you, let me fix that real quick

@fluvf
Copy link
Contributor Author

fluvf commented Dec 18, 2023

I think that rebase worked, can't see any obvious issues with it
Nevertheless, please test the terminal list file parsing well
Here's what I used to test it:

# a.desktop
b.desktop:action
b!a.desktop
!.desktop
a!.desktop
!a.desktop
.desktop
a.desktop:action!
a.desktop
a.desktop:
a.desktop       :::     action
a    : action

xdg-terminal-exec Outdated Show resolved Hide resolved
debug "$entry_id : $action_id"
;;
# Catch and complain on invalid lines
*)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is too aggressive, we need to silently drop unrecognized stuff, only react on invalid entries (things containing .desktop, but otherwise invalid).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you rather it be a debug message, or nothing at all?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked validate_entry_id(), validate_action_id(), we could use them if line contains .desktop and produce error on negative result. And just do not bother with anything not explicitly recognized and not containing .desktop.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...not an error, a warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this more because all the logic is in one place
Simpler to write tests for too

I changed the catch all to a debug message, is this good?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the topic, as the file format is part of the proposed spec, I think the reference implementation should be responsible for validating the files. At least to some degree

This at least catches all the cases I could think of
A fun bonus feature, there now can be whitespace between the IDs, allowing for more readable list files
Less code
While here, improve comments and order of checks
Makes it look prettier
Uses the given action ID as a flag to signify that the Exec value should be read, by checking if it's set or not
One less variable to carry around
Makes writing tests more straight forward and allows hiding checks conditionally
This makes carrying `$de_checks` unnecessary
The spec refers to them as identifiers, makes it clearer what the variable holds
Now that they're separated, these describe them slightly better
Also touch all relevant comments / debug messages
Various changes in an effort to make `DEBUG=1` output more readable
'TryExec') check_entry_tryexec "$value" ;;
'Hidden') check_entry_hidden "$value" ;;
# Only read key from requested action group, marked by unset ID
'Exec') [ -z "$action_id" ] && check_entry_exec "$value" ;;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails on any explicitly specified action, needs to be wrapped in full if then fi

debug "found '$line' directive${XTE_CACHE_ENABLED+ (ignored)}"
debug '' " $config_path"
# Let `read` trim leading/trailing whitespace from the IDs
while IFS=":$OIFS" read -r entry_id action_id; do
Copy link
Owner

@Vladimir-csp Vladimir-csp Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this splits action not only on :, but on whole original IFS, falsely consuming invalid lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants