Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A single executable script format that is operable in both UNIX and WINDOWS environment.

License

NotificationsYou must be signed in to change notification settings

ChewKeanHo/PolygotScripts

Repository files navigation

Holloway's Polygot Scripts

This is a reference repo serving as a sharing and quality control for my polygotscripts:The same script can be operated in both UNIX and WINDOWS OSes. Thisscript is generally used various multi-system distributions and fleet controlinitialization where maintaining multi-OSes end products can be easily done.

Why It Matters

Mainly for multi-os decentralized packaging usage:

  1. 1 common starting point - less communication errors; more control overthe package installation.
  2. Maintainable and documentable - 1 single start point; 1 set ofdocumentation only; 1 easy way to maintain the starting point command.
  3. Simple and modular - can easily drill down the errors due tomodularization and use the most basic commands available in both OSes.

The Products

The products are located in the root repository in various versions:

  1. posix-batch-powershell.sh.ps1.cmd -capable of running in:

    1. POSIX Shell mode; AND
    2. BATCH mode; AND
    3. POWERSHELL mode.
  2. posix-batch.sh.cmd - capable of running in:

    1. POSIX Shell mode; AND
    2. BATCH mode; AND

Note

PowerShell knows how to execute batch script. No auto-correction isrequired.

  1. posix-powershell.sh.cmd - capable of running in:
    1. POSIX Shell mode; AND
    2. POWERSHELL mode.

Important

When executed in Batch mode, it will auto-correct itself to PowerShell andexecute it from there.

  1. posix-powershell.sh.ps1 - capable of running in:
    1. POSIX Shell mode; AND
    2. POWERSHELL mode.

File Extensions

While UNIX systems do not demand for file extensions, Windows do have itscomplex and heavy requirement for it. As a practice, the file extension shallalways be lead by the UNIX (.sh*) and ends with Windows (either*.cmd forBatch initialization or*.ps1 for PowerShell initialization).

For the highest portability, I recommend keeping the initialization with Batchmode since its execution can auto-correct to PowerShell mode when available(Referposix-powershell.sh.ps1 for how it's done).

Hence, this is the Polygot script's file extension I would recommend:

filename.sh.ps1.cmd       # start by Batchfilename.sh.cmd.ps1       # start by PowerShellfilename.sh.cmdfilename.sh.ps1

Maintain Simplicity for Sanity

It is always advisable to keep this script as simple as calling the OS-specificinitializing command rather than develop afat binary like executable script.

In case you don't know, coding all 3 types of scripts and compile into 1manually can be a cumbersome task as the output file can easily become 3xlarger. Should it be too complex, you should use proper programming languageslike Go or Rust.

PleaseDO NOT abuse it. You have been warned!

License

This project is licensed underMIT License.

About

A single executable script format that is operable in both UNIX and WINDOWS environment.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp