Code Monkey home page Code Monkey logo

picobat's Introduction

Quick starting guide

Picobat is an open source command prompt meant to implement a superset of cmd.exe script language (known as batch by most developers). It is designed to be as simple to use as possible, reliable, portable and lightweight.

Getting started with Picobat

Firstly, if you have never used cmd or an equivalent interpreter before, you should definitely consider reading a tutorial about batch programming. On the other hand if you are already familiar with batch, just open pbat and start typing some commands ! Picobat batch dialect is almost compatible with cmd.

If you use Picobat on windows, the only file extension provided is .pbat by default (to avoid trashing your OS with potential conflicts). However, calling a .bat or .cmd script from inside Picobat, leads them to get executed by Picobat.

Downloading Picobat

The latest release of picobat is available here. Extract the archive and start playing with pbat in the extracted folder.

Picobat changes

Once installed, it is quite straightforward to play with Picobat, especially if you are quite familiar with cmd. However, there is a couple of thing out there you have to know about.

On one hand, there is a couple of differences between Picobat and cmd :

  • The HELP system is different from the original cmd help system. On the first time you run the command, you need to genérate the whole documentation using:

      help /b
    

    Once all the data has been generated you can use it as the help command, but beware, it's fairly improved.

  • There is a few FOR modifications:

    • Empty line are processed by FOR /F. This behaviour can be disabled using:

          SETLOCAL EnableCmdlyCorrect
      
    • Multiples lines can be used as input for FOR /F.

    • Tokens can be specified in reverse order and can also overlap without bug.

  • Some undocumented but useful variables from cmd are still lacking (Though %=EXITCODEASCII% is now supported).

  • Picobat has no inconsistencies with escaped characters with ^, it requires only one escape.

  • DIR /b does not automatically return absolute paths.

  • Support of START is a bit tricky under some platforms and some of the options or the whole command might not be provided depending on your system configuration if you use *nix.

On the other hand, Picobat also provides you with with a bunch of extensions:

  • A full set of extensions to support floating points arithmetics through SET and IF:

    • New SET /a commands extensions to perform operations on floating point numbers.

    • Extensions for IF command to automatically detect floating-point and compare floating-point numbers.

  • The amazing possibility to define functions and procedures in batch using the Picobat specific DEF command:

      DEF ADD=(set /a $1=$2+$3)
      ADD result 4 3
      ECHO result = %result%
    
  • The ground-breaking possibility to specify logical expressions using AND and OR and the new IF extensions, like in the following example:

      IF [ [ !ok! EQU 1 ] and [ defined file ] ] (
       :: some code 
      )
    
  • A module system allowing extension loading at run-time. This offer numbers of possibilities from graphical user interfaces to networking extensions. Currently, the only module provided is the BATBOX module.

  • To speed up parsing, Picobat loads files entirely in memory at startup. If the file gets modified during its execution, it is reloaded and Picobat restarts on the next line (counting lines from the begining). This can also be disabled using:

      SETLOCAL EnableCmdlyCorrect
    
  • As can be seen in the previous code, ::-style comments can be used inside blocks.

  • All the FOR modifications described above.

  • Enhanced GOTO and CALL that can use a file and a label at the same time and ignore errors:

      GOTO :mylabel myfile.bat /Q
      CALL /e :mylabel myfile
    
  • Extended HELP providing search capabilities and help in various formats including HTML.

  • An extension to the FIND command to use simple regular expressions:

      echo match my regular expression | FIND /e "match * regular expression"
    
  • The FIND and MORE commands are provided as internal commands.

  • New internal commands XARGS and WC inspired from their *nix counterparts:

    • XARGS runs a command taking command parameters on the standard input.

    • WC counts line or words or bytes in a file.

          :: Count lines in subdirs 
          dir /s /b /a:-D . | xargs wc /l
      
  • New external command DUMP to dump hexadecimal code.

  • New SHIFT extensions and new %+ variable containing the remaining arguments.

Troubleshooting

If you have some questions about or need some help with Picobat, please feel free to join Picobat's official discord at: https://discord.gg/w4KtdCv

For more documentations and updates, please see the official Picobat website.

What's in this folder ?

There is a few interesting things in this directory that you might need:

  • BUILD.readme : A text file describing how to build Picobat

  • WHATSNEW : A log of the changes made to Picobat

  • THANKS : A list of all the contributors to the project.

  • GUIDELINES : A text files giving guidelines on how to modify Picobat.

  • COPYING.* : The license of the project and of projects used by Picobat.

picobat's People

Contributors

darkbatcher avatar tsnake41 avatar xenoxis avatar

Stargazers

Joel Van Eenwyk avatar Tove Anine avatar  avatar  avatar polyskull avatar  avatar  avatar  avatar Murat Kirazkaya avatar astrolemonade avatar  avatar Rashil Gandhi avatar Karanveer Chouhan avatar Radoslav Georgiev avatar Pooia avatar parsa mahmoudy avatar Kacper Kostka avatar zaktabyte avatar  avatar

Watchers

 avatar  avatar  avatar

picobat's Issues

Some pointer about parsing and executment

I intend to make some changes to the PicoBat project, but I have limited knowledge. Would it be possible for you to provide me with the documentation of PicoBat, or a document that explains how the algorithm is handled (in .pdf, .docx or other format)? Also, I'm not sure what ESTR stands for as I've seen it mentioned several times.

stateDiagram-v2
    direction LR
    [*] --> pBat_RunBatch
    pBat_RunBatch --> pBat_RunLine
    pBat_RunLine --> pBat_RunLine: !(pIn->bEof)
    pBat_RunLine --> pBat_ParseLine
    pBat_ParseLine --> pBat_RunParsedLine
    pBat_RunParsedLine --> RPL
    state RPL {
        direction LR
        pBat_SkipAllBlanks --> pBat_ExecOperators
        pBat_ExecOperators --> pBat_PopStreamStackUntilLock
        pBat_PopStreamStackUntilLock --> pBat_SetStreamStackLockState
        pBat_SetStreamStackLockState --> pBat_ExecOutput
        
    }
    RPL --> pBat_RunCommand
Loading

I did this in a short time without details, but this is the progress I was able to solve, it is difficult to find the right way because there is too much code.

Path name is case sensitive on linux (ubuntu 22)

Screenshot from 2024-02-09 18-49-18

When i am trying to navigate to my '_Temp ' folder... the sutocomplete feature of picobat has no issues with the "t" (small T) and "T" (Capital T)... but as linux (ubuntu 22) uses case sensitive pathnames... the simple CD with picoBat didn't work,

Let me know, if you need additional info from my side...

Can we create custom subfunc?

It is possible EnableDelayedExpansion for substring.
like: %var:~10,5%

But if we can make our custom subfuncs like

  SET EnableDelayedExpansion
  SET Var=HeLLO
  DEF :a=(out Var.ToLower() /*c code*/ )
  ECHO result = %result:a%

hello

  • Please give positive or negative feedback to this idea.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.