BATsh

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

      (for the word list of for VAR in GLOB; do ... done). Single-quoted
      and double-quoted patterns are NOT expanded (POSIX behaviour).
      If no file matches the pattern, the literal pattern is returned
      unchanged (nullglob-off behaviour, which is the shell default).
      Two new helpers are added to BATsh::SH: _glob_expand() (expand one
      word) and _glob_expand_args() (convenience wrapper over a list).

    - t/0009-new-vars.t: new test file, 25 tests (NV01-NV25) covering
      all three feature areas above. Added to MANIFEST.

    - POD updated: BATsh.pm BUGS AND LIMITATIONS now records that
      %VAR:~n,m% / %VAR:str1=str2% and all dynamic pseudo-variables are
      supported; the SH filename-globbing limitation item is removed.
      BATsh::Env Variable Expansion section documents all new forms.
      BATsh::SH Supported Features table lists glob expansion.

    - Version bumped to 0.05 in lib/BATsh.pm, lib/BATsh/CMD.pm,
      lib/BATsh/SH.pm, lib/BATsh/Env.pm, Makefile.PL, META.yml,
      META.json, and README.

0.04  2026-06-07 JST (Japan Standard Time)

Changes  view on Meta::CPAN

      run INA_CPAN_Check::selfcheck_suite() as check3 and abort the
      build if any test file fails the plan-sanity check (disable with
      --no-check3). Bump $PMAKE_BAT_VERSION to 0.34.
    - t/lib/INA_CPAN_Check.pm: pass \@files / \@pm_files (a reference)
      instead of [ @files ] (an anonymous copy) to _find_pm_t() in
      _scan_code(), check_D(), check_E(), and check_K(). The copy form
      meant the collected file list never reached the caller, so E1
      (no shebang in lib/*.pm) and K3 (return { %hash } form) silently
      scanned zero files and always passed.

    - Documentation: BATsh.pm BUGS AND LIMITATIONS corrected. It no longer
      claims SH-mode background execution is unsupported (it is supported
      for external commands; see above and BATsh::SH), and it now clarifies
      that non-builtin commands (FINDSTR, SORT, etc.) are invoked as
      external programs rather than "unsupported". README and BATsh.pm POD
      additionally enumerate previously undocumented limitations: CMD
      "%VAR:~n,m%" / "%VAR:str1=str2%" and dynamic "%RANDOM%/%DATE%/%TIME%/
      %CD%" variables; SH arrays, filename globbing, "~" tilde expansion,
      brace expansion, and the trap/getopts/select/alias/declare/eval/exec
      builtins and set -e/-u/-x options; and the shared (no sub-shell)
      "( ... )" grouping common to both modes.

Changes  view on Meta::CPAN

      command asynchronously and returns immediately. On Win32 the job is
      spawned via system(1, ...) (P_NOWAIT, PID returned); on Unix it is
      started through /bin/sh without a Perl fork, capturing the job PID
      via the shell's $! into a sysopen O_CREAT|O_EXCL temp file (Pure
      Perl, 5.005_03). The new $! parameter expands to the most recent
      background PID (empty before any job); $? is 0 on a successful
      launch (the job's own exit status is not awaited). Built-ins,
      functions, assignments and control words ignore the trailing "&"
      and run in the foreground; "&&", ">&"/"2>&1", quoted and escaped
      "\&" are not treated as background. No job control; CMD-mode "&"
      remains a sequential separator (see BUGS AND LIMITATIONS).

    - eg/05_cmd_comprehensive.batsh: the "IF ERRORLEVEL" diagnostic line
      "ECHO   ERRORLEVEL>=0: ELTEST=%ELTEST%" contained a bare ">", which
      CMD mode correctly treats as output redirection (matching cmd.exe).
      As written, the message was silently redirected to a file named
      "=0:" instead of being printed, and that stray file was created in
      the current directory each time the example ran (including under
      "make test" via t/9070-examples.t). The ">" is now caret-escaped
      ("ECHO   ERRORLEVEL ^>= 0: ELTEST=%ELTEST%"), so the line prints
      as intended and no file is written.

Changes  view on Meta::CPAN

      stderr (2>), stderr-to-stdout (2>&1), stdout-to-stderr (1>&2).
      Supported in both CMD mode and SH mode.
    - SH here-documents on STDIN: cmd <<DELIM ... DELIM, <<-DELIM (strip
      leading tabs), and <<'DELIM' (literal, no expansion). Body is
      materialised to a temp file created with sysopen O_CREAT|O_EXCL
      (Pure Perl, 5.005_03) and fed through the existing "< file" path,
      so both built-ins (read) and external commands see it on STDIN.
      Top-level mode dispatch is here-document aware, so uppercase body
      lines are not misrouted to CMD mode. Single here-document per line;
      here-strings (<<<) and same-line pipeline/compound combos are not
      supported (see BUGS AND LIMITATIONS).
    - cmd.exe batch-parameter tilde modifiers: %~0, %~f1, %~dp0, %~nx1,
      %~n0, %~x0, %~p1 etc. (f d p n x modifiers, combinable).
    - SET /P VAR=Prompt  interactive prompt input from STDIN.
    - $0 normalised to absolute path via File::Spec on run().

    [BATsh::Env]
    - Variable names are now stored and looked up in uppercase, matching
      cmd.exe's case-insensitive environment variable behaviour.
      SET myvar=x  followed by  ECHO %MYVAR%  now correctly outputs "x".
    - Added $DELAYED_EXPANSION package variable (default 0).

README  view on Meta::CPAN

        perl Makefile.PL
        make
        make test
        make install

    No non-core dependencies are required.

REQUIREMENTS
    Perl 5.005_03 or later. Core modules only. No external shell required.

BUGS AND LIMITATIONS
    Commands that are not built in -- "FINDSTR", "SORT", "MORE", "CHOICE",
    "TIMEOUT", "XCOPY", "ROBOCOPY" and the like in CMD mode, and any
    non-builtin program in SH mode -- are NOT reimplemented in Perl. They
    are invoked as external programs (via Perl's "system"), so they work
    only where the host operating system provides the corresponding
    executable (e.g. FINDSTR.EXE on Windows). Only the built-in command set
    is guaranteed to run identically on every platform.

    The built-in CMD interpreter does not implement:

lib/BATsh.pm  view on Meta::CPAN

  map=([k]=v ...), map[k]=v                     -- associative arrays
  ${arr[i]}, ${map[key]}, $arr (== ${arr[0]})   -- element access
  ${arr[@]}, ${arr[*]}, ${#arr[@]}, ${#arr[i]}, ${!arr[@]}
  unset arr, unset arr[i]
  source / . file

=head1 REQUIREMENTS

Perl 5.005_03 or later. Core modules only. No external shell required.

=head1 BUGS AND LIMITATIONS

Commands that are not built in -- C<FINDSTR>, C<SORT>, C<MORE>, C<CHOICE>,
C<TIMEOUT>, C<XCOPY>, C<ROBOCOPY> and the like in CMD mode, and any
non-builtin program in SH mode -- are B<not> reimplemented in Perl. They
are invoked as external programs (via Perl's C<system>), so they work only
where the host operating system provides the corresponding executable
(e.g. F<FINDSTR.EXE> on Windows). This is by design: only the built-in
command set is guaranteed to run identically on every platform.

The built-in CMD interpreter does not implement:



( run in 2.199 seconds using v1.01-cache-2.11-cpan-0b5f733616e )