python

package module
v0.0.37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

README

contrib/python

contrib/python provides sandboxed python and python3 commands for gbash, backed by github.com/ewhauser/gomonty.

Status

  • opt-in through github.com/ewhauser/gbash/contrib/python
  • bundled by contrib/extras
  • not part of gbash.DefaultRegistry()
  • cgo-backed through gomonty

Supported Command Surface

The v1 command intentionally stays small:

  • python -c 'code'
  • python script.py
  • python with source from stdin
  • --help
  • --version

Unsupported flags such as -m and extra script arguments are rejected with a usage error.

Builtin print(...) writes to gbash stdout. Upstream Monty still rejects print(..., file=...), so redirecting builtin print to arbitrary streams is not supported.

Sandbox Rules

  • filesystem access flows through commands.Invocation.FS
  • environment access flows through commands.Invocation.Env
  • relative paths resolve from the gbash working directory
  • print output goes to gbash stdout
  • command execution never escapes to the host OS

gomonty is cgo-backed and requires a supported target archive. When the native bindings are unavailable, the command exits non-zero with the bundled stub diagnostic from gomonty.

Registering The Commands

registry := gbash.DefaultRegistry()
if err := python.Register(registry); err != nil {
    return err
}

Register installs both python and python3.

Documentation

Overview

Package python registers the optional sandboxed python and python3 commands for gbash.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(registry commands.CommandRegistry) error

Types

type Python

type Python struct {
	// contains filtered or unexported fields
}

func New

func New(name string) *Python

func (*Python) Name

func (c *Python) Name() string

func (*Python) Run

func (c *Python) Run(ctx context.Context, inv *commands.Invocation) error

func (*Python) RunParsed

func (c *Python) RunParsed(ctx context.Context, inv *commands.Invocation, matches *commands.ParsedCommand) error

func (*Python) Spec

func (c *Python) Spec() commands.CommandSpec

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL