Open TiddlyTweeter opened 5 years ago
A .bat file can run in lin*x, but it has to be marked as executable (e.g. chmod 764 polly2.bat). But for some reason the command to launch PS isn't "powershell", but "pwsh". and you can't use the backslash (.\pwsh) but instead the forward slash (./pwsh).
So it seems like the main way to distribute polly is via two distributions, one for unx, and one for Windows. This might not be so hard. There can be two branches for distribution. One for unx, and the other for Windows, both based on master with the only difference being the initial batch files.
Just FYI I think it would be relatively easy in do-settings.ps1 to add PS version and platform detection and auto generate appropriate .bat / .sh / .ini files, either by copying templates or by dynamically building the needed files.
Q: Would you like me to work on that? Would the permissions issue remain in the way?
@TiddlyTweeter That would be neat. But how would do-settings.ps1 get launched in the first place? If you generate .sh files on the fly, you will probably also need to modify them with a command like:
chmod u+x myfile.sh
This adds the executable permission at the user level. chmod is on all Linux platforms, afaik. Probably Mac too?
Hopefully that's possible from script. I guess we'll find out.
@Marxsal That would be neat. But how would do-settings.ps1 get launched in the first place?
PROPOSED FIRST USE SETUP LOGIC
On first install the app. dir contains only ...
setup-Linux.sh
setup-Mac.sh
setup-Windows.bat
polly.ps1
./lib
The "setup" files simply launch polly.ps1 with the appropriate version of PS. The Windows .bat to contain detection whether "pwsh" is present and runs using it, else runs with powershell.
polly.ps1 detects that settings.ini is missing, and invokes ./lib/do-settings.ps1.
do-settings.ps1 creates basic bat/sh for the run environment (determined by PS version + IsPlatform) ...
... applies files permissions to them where needed
... then deletes "setup.*" files.
... then does settings.ini creation as we have it already.
IF the user quits just after (5) its ok. Next time they launch Polly it will not need step 1, but otherwise work the same just using any of the created "batch" files that are now "environment specific".
UPDATE: I am currently assuming that Linux & MacOS would have identical ".sh" files and permissions process.
UPDATE: I changed the proposed names for setup script files above on "first install"
Hi @Marxsal could you test for me what happens in a Linux PS6 console when you enter ...
[Environment]::EDITOR
... and any of these on a file ...
chmod u+x test.sh
chmod u+x *.sh
(will take wildcards?)
Start-Process -FilePath "chmod" -ArgumentList "u+x test.sh" -NoNewWindow
(Won't take wildcards? Does main process continue after chmod is finished?)
[Environment]::EDITOR
Returns nothing. I suspect that it is one of those sometimes-used variables. You might have to check for the most popular/likely editors (which geany, which nano, which vim, which vi, which emacs) and then, if all else fails, print a message to the user telling them what they need to do.
chmod u+x test.sh
chmod u+x *.sh
(will take wildcards?)
Start-Process -FilePath "chmod" -ArgumentList "u+x test.sh" -NoNewWindow
These all work, and return you to the PS6 terminal.
[Environment]::EDITOR
Returns nothing. I suspect that it is one of those sometimes-used variables. You might have to check for the most popular/likely editors (which geany, which nano, which vim, which vi, which emacs) and then, if all else fails, print a message to the user telling them what they need to do.
@Marxsal, one further question about Linux. Does it support launch by "file type" like Windows, e.g. on Win you can open a text editor simply via Start-Process "file.txt"
since the type has a defined (registry entry) association to an ".exe".
I updated this issue on what a "release" might look like at https://github.com/Marxsal/polly/issues/6#issuecomment-522207438
Does it support launch by "file type" like Windows, e.g. on Win you can open a text editor simply via
Start-Process "file.txt"
since the type has a defined (registry entry) association to an ".exe".
I would say "not reliably". I tried it and although it opened the file in a terminal window, the window was "broken", with prompts and text appearing at the wrong locations on the screen and keystrokes obscured.
What apparently works on Debian/Ubuntu distributions is to type
editor temp.txt
this will invoke the default editor. But it may not apply to all distributions.
Much as I value theoretical idea of Linux it sounds like a nightmare to work with.
TBH, I think it may be easier to just create settings.ini in Powershell??
TBH, I think it may be easier to just create settings.ini in Powershell??
I thought that was what your were planning on doing ??
I thought that was what your were planning on doing ??
Yeah. Sort of. But not because of lack of a text editor you could rely on.
Now its more of an imperative to avoid hassle.
I'd hope we can produce (fingers crossed) a reliable cross-platform system. So, right now I'm thinking a "universal" release might look like this ...
According to platform appropriate settings.ini and polly-once.'platform' and polly-auto.'platform' "batch" files would be created on first run. (This assumes ".sh" won't run on Win & ".bat" won't run on Linux or Mac [it might???])