termux / termux-widget

Termux add-on app which adds shortcuts to commands on the home screen.
https://f-droid.org/en/packages/com.termux.widget
Other
985 stars 114 forks source link

Shortcuts that are symlinks are dereferenced #59

Open Cigaes opened 3 years ago

Cigaes commented 3 years ago

Problem description

When a shortcut is a symlink, it is shown it is own name in the list to create the widget, but then the actual shortcut uses the target of the symlink.

Steps to reproduce

  1. Create .shortcuts/host1 with basically ssh $0.
  2. ln -s host1 host2
  3. Browse to add a widget, select host2 in the list.
  4. Use the new widget.

Expected behavior

I would expect a widget named host2 that ssh me to host2. Instead, I get a widget named host1 that ssh me to host1.

Additional information

It used to work with Termux:Widget 0.12. I had to re-create all widgets after recently upgrading to 0.13.

ghost commented 3 years ago

Intended behavior (canonical paths), please check the answer at https://github.com/termux/termux-widget/issues/57#issuecomment-929058585.

Cigaes commented 3 years ago

I have read the discussion for this issue and the ChangeLog for v0.13, and neither address the exact issue I am pointing. Are you sure this is not an unintentional change that is a side effect of an intentional one?

At the very least, the fact that the shortcut appears with its source name in the list but is created with the target name is inconsistent and misleading and needs to be fixed.

agnostic-apollo commented 3 years ago

Sorry, that's my fault. I forgot to add the symlink target patch even though it came in my mind. That is likely the issue. Will try fixing it soon.

https://github.com/termux/termux-app/blob/v0.117/app/src/main/java/com/termux/app/RunCommandService.java#L179

https://github.com/termux/termux-widget/blob/v0.13.0/app/src/main/java/com/termux/widget/TermuxWidgetProvider.java#L228

The name needs to be generated from absolute path too instead of canonical

https://github.com/termux/termux-widget/blob/v0.13.0/app/src/main/java/com/termux/widget/TermuxCreateShortcutActivity.java#L126