termux / termux-api-package

Termux package containing scripts to call functionality in Termux:API.
MIT License
994 stars 314 forks source link

command never returns if title contanins space #130

Open anirudhsanthosh opened 3 years ago

anirudhsanthosh commented 3 years ago

Screenshot_2021-04-17-19-37-02-65_84d3000e3f4017145260f7618db1d683 Screenshot_2021-04-17-19-36-21-83_84d3000e3f4017145260f7618db1d683 Screenshot_2021-04-17-19-36-07-12

Problem description

if the value title option in command contains white space the command never returns

Steps to reproduce

termux-share -a send -t "ueueue ejejje ejeie" proccessedVideos/1618662889.mp4

Expected behavior

the command should be executed and show a chooser activity but it doesnt Additional information

i tried updating and upgrading termux api, apt, even updated app

but it still exist

please check the time and command i used in termux i waited for 1 minute but it is not working

ghost commented 3 years ago

That's a termux-api script bug as it doesn't handle arguments properly. https://github.com/termux/termux-api-package/blob/master/scripts/termux-share#L36-L51

agnostic-apollo commented 3 years ago

@xeffyr I was looking at various termux-api-package scripts and noticed params and even whole commands were being added to string variables, why weren't bash arrays used? Was it just a poor design decision from the start that has continued on or was it something else?

ghost commented 3 years ago

I haven't wrote these scripts but I assume they were just "quick implementation" without care about argument passing safety etc.

agnostic-apollo commented 3 years ago

Yeah, probably, should be fixed in future I guess.

And instead of using a gazillion echo commands to print help text, a simple literal cat heredoc can be used like here. Would make it easier to write and update the text, no escaping required for like double quotes and for preventing variable expansion, also easier to see/maintain the 70-80 character column width for termux, also help text can be directly copied to somewhere else like a README, and obviously looks much cleaner. This also affects termux-packages.

cessywauu commented 2 years ago

Ano, pravděpodobně by to mělo být v budoucnu opraveno.

A místo použití gazillionových echopříkazů k tisku catpomocného textu lze použít jednoduchý doslovný heredoc jako zde . Usnadnilo by to psaní a aktualizaci textu, není třeba unikat pro dvojité uvozovky a pro zabránění variabilnímu rozšiřování, také snadněji vidět/udržovat šířku sloupce 70-80 znaků pro termuxy, také pomoci text lze přímo zkopírovat jinam jako a README, a zjevně vypadá mnohem čistší. To také ovlivňuje termux-packages.

anirudhsanthosh commented 2 years ago

this is how i did the workaround

/data/data/com.termux/files/usr/libexec/termux-api Share --es action send --ez default-receiver true --es title "__YOUR TITLE__" --es file "$(realpath __path to file__)"

i am not good with bash right now so i directly invoked the api binary it works fine exept if you have a double quot in your title