← Back to DAGDA | Support | Source: https://github.com/RusticStack/skua-tools
Skip to content

About

file, dos2unix and unix2dos for Skua Bash (Git Bash-compatible output)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

29 Commits

Folders and files

Repository files navigation

skua-tools

file, dos2unix, unix2dos, clear, ps, pgrep, pkill, gzip/gunzip/zcat, unzip, zip, xxd, column, iconv, start, egrep, fgrep, perl, id, python/python3 and wget for Skua Bash, the bash-compatible shell bundled with Skua on Windows. Git Bash ships these (libmagic file 5.4x, dos2unix 7.x) and coding agents use them, for example git ls-files | xargs file to see line endings. No existing Rust implementation gave Git Bash's output, so these are small native programs written for that output.

  • file: text (ASCII, UTF-8, UTF-8 with BOM, ISO-8859, extended ASCII; CRLF/CR/LF terminators, no terminators, very long lines, escape sequences), scripts by #! (sh, bash, python, node, perl, ...), JSON, XML, HTML, PE/ELF/Mach-O executables (Mach-O without libmagic's flags:<...>), PNG, GIF, JPEG, PDF, archives, empty, directory, symbolic links; anything else is data. Options -b -L -h -i -N -F -f --mime-type --mime-encoding. Not done: libmagic's source-language guesses (C source), gzip header details.

  • dos2unix / unix2dos (one program; the name picks the direction): in place, -n IN OUT, stdin to stdout, -q -k -f -b -r -m, binary files skipped, dos2unix 7.x messages.

  • clear: Git Bash's ncurses clear (\e[H\e[2J\e[3J for xterm-like terminals, -x, -T, cygwin/screen/dumb, the same errors); names Git Bash's terminfo lacks are cleared like xterm.

  • ps: Git Bash's (Cygwin) ps table layouts (default, -l, -f, -s, aux, -e, -p, -u) over all Windows processes (PID = Windows PID).

  • pgrep / pkill (one code base): procps-ng behaviour (Git Bash has neither). -f -l -a -x -i -n -o -c -v -u -P ..., exit 0/1/2/3. Signals that end a process on Unix all terminate it; STOP/TSTP are refused. Never matches itself or an ancestor.

  • gzip / gunzip / zcat (one program, the name picks the mode): GNU gzip 1.14 messages and exit codes; compressed bytes and sizes differ (miniz_oxide). No .Z.

  • unzip: Info-ZIP UnZip 6.00 output (-l -v -Z -t -p -d -o -n -j -x ...). bzip2, deflate64, LZMA and encrypted entries are skipped.

  • zip: Info-ZIP Zip 3.0 behaviour from its documentation (Git for Windows has no zip, so no reference run): -r -j -D -q -0..-9 -x -i -u -f -d -m -@ -T. No Zip64 writing, encryption or comments.

  • xxd: byte-for-byte with Git Bash's xxd (all dump modes and -r).

  • column: util-linux 2.40 column (fill, table and JSON modes).

  • iconv: Git Bash's iconv (GNU libiconv 1.19-compatible) behaviour for UTF-8/16/32, UCS, ASCII, Latin-1, Windows-125x, ISO-8859-x, //TRANSLIT, //IGNORE; CJK and a few others follow WHATWG tables; the //TRANSLIT table is Skua's own, generated from the Unicode Character Database (tools/gen_iconv_translit.py).

  • start: cmd.exe /c start "" ARGS with complete escaping; SKUA_START_DRY_RUN=1 prints instead of running.

  • egrep / fgrep: grep -E / grep -F launchers (the sibling grep.exe first, else grep on PATH).

  • id: Git Bash's (GNU coreutils 8.32 on Cygwin) id with Git for Windows' default nsswitch.conf: uid/gid from the process token with Cygwin's SID mapping (0x30000 + RID for local accounts, well-known SIDs fixed), user names from Windows accounts, no group names (cannot find name for group ID, status 1), the current user's groups = the primary group. All options, errors and statuses as Git Bash's; --version says id (skua-tools).

  • perl: launcher only. Runs Git for Windows' perl: SKUA_PERL, else the first Git for Windows install found (git.exe on PATH, %ProgramFiles%\Git, %LOCALAPPDATA%\Programs\Git, InstallPath under HKLM/HKCU\SOFTWARE\GitForWindows, Scoop) that has perl.exe in usr\bin, ucrt64\bin, mingw64\bin or clangarm64\bin. An install is recognised by cmd\git.exe only (the path Git for Windows promises to keep; 2.56 moved mingw64 to ucrt64). Not found: one line saying what was looked for, status 127. The lookup is skua_tools::gitwin.

  • python / python3: launchers, not interpreters. Each finds a real Python and runs it with the same arguments, stdio and status: per PATH directory the asked-for name, then the other one (a python.org install or a venv has python.exe only), skipping the App Installer stubs in WindowsApps (zero-length app execution aliases that print an install hint or open the Microsoft Store) and copies of the launcher; then the py launcher (py -3 for python3). No Python: one line and status 127, never a Store window.

  • wget: GNU Wget's common options on top of Windows' curl.exe (%SystemRoot%\System32\curl.exe, else PATH): -q -v -nv -O FILE|- -P DIR --header -c --no-check-certificate -T -t -U --post-data --post-file, file name from the URL (index.html, name.1 when it exists), redirects followed, exit status 0/1/2/3/4/5/8 as GNU Wget. Other options are refused with a message. --version says it is the skua-tools wget on curl, not GNU Wget.

Linux and macOS

Everything builds, is tested and packaged on x86_64-unknown-linux-gnu and aarch64-apple-darwin too (CI: .github/workflows/skua.yml); Windows behaviour is unchanged. Off Windows:

  • file, dos2unix/unix2dos, clear, gzip/gunzip/zcat, unzip, zip, xxd, column, iconv behave as above.
  • id, ps, pgrep, pkill: there is no Cygwin layout to reproduce, so each runs the system's own (the first on PATH that is not itself) with the same arguments, in place of itself; none: NAME: command not found, status 127.
  • perl: SKUA_PERL, else the system's perl on PATH.
  • python / python3: the asked-for name on PATH, then the other one (executable files only, copies of the launcher skipped); no py launcher, no Store stubs.
  • start: the desktop's opener (open on macOS, xdg-open elsewhere), once per argument; a leading "" (the Windows title) is dropped. SKUA_START_DRY_RUN=1 prints open ARG lines.
  • egrep / fgrep: grep next to the binary, else on PATH.
  • wget: curl on PATH.
  • A closed stdout (EPIPE) exits 141 as on Windows.

tools/package-unix.sh --target <triple> --out <dir> [--version <v>] builds the release binaries and writes skua-tools-<version>-<target>.tar.gz (bin/ with gunzip, zcat and unix2dos as links, LICENSE, THIRD-PARTY.txt from cargo-about, SHA256SUMS) and its .sha256.

Built for Skua's Windows bundle by Skua Bash's skua/build-uutils.ps1 (entry in skua/uutils.toml). MIT.

About

file, dos2unix and unix2dos for Skua Bash (Git Bash-compatible output)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages