tessus / joplin-scripts

scripts for Joplin
53 stars 3 forks source link

Fix for Windows. #2

Closed 12425 closed 3 years ago

12425 commented 3 years ago

Windows sqlite3.exe generates file in dos format and the extra \r causes wrong curl command and deletion failure. Instead of cat lines, use awk to trim the \r.

tessus commented 3 years ago

I'm not a Windows user so I have a few questions and comments.

I never call sqlite3.exe anywhere in the script. Or does LSW translate sqlite3 to sqlite3.exe? If so, wouldn't it make more sense to actually install the Linux sqlite under LSW?

The reason why I don't really want to use awk is that it might not be installed, even though it's pretty standard these days.

There are 3 options:

12425 commented 3 years ago

Do you mean WSL? I'm not running WSL, It's just git and sqlite3 for Windows. Yes, in Windows most files have extension, and if you run sqlite3 it will actually locate sqlite3.exe. The possible extensions are in this environment variable:

echo $PATHEXT
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.wlua;.lexe

I agree to use sed instead of awk.

12425 commented 3 years ago

We don't have to use -i and this change removes all trailing whitespaces.

for id in `sed 's/\s\+$//' $TMPFILE`
tessus commented 3 years ago

How do you run a bash file in Windows? As far as I know this can only be done when using the Linux Services for Windows. Either way, how can I check if it is actually running on Windows?

this change removes all trailing whitespaces.

Ok, thanks. This should work on Linux and Windows.

12425 commented 3 years ago

You can simply download PortableGit-*.7z.exe which is a self-extracting binary. Run the extracted git-bash.exe and it simulates a bash environment. I ran jnrmor inside it. At a low level it runs cat.exe, sed.exe etc. which are also extracted. That's why (I guess) the generated file is in dos format.

tessus commented 3 years ago

Ah, I see.

Ok, this change certainly doesn't hurt and if it fixes an issue on Windows, why not. Thanks!