Skip to content

exec() generates shell exec instead of running commands; pipe detection too aggressive #94

@noahgift

Description

@noahgift

Summary

Several issues encountered when using bashrs for a ground truth comparison script in whisper.apr:

Issue 1: exec() generates shell exec instead of running commands

Expected Behavior

exec("cargo build --release");

Should generate shell that runs the command.

Actual Behavior

Generates:

exec 'cargo build --release'

Which replaces the current shell process instead of running the command.

Workaround

Manual edit of generated script to remove exec wrapper.


Issue 2: Pipe operator detection too aggressive in string literals

Code that fails

echo("|     whisper.apr      |     whisper.cpp      |     HuggingFace      |");

Error

error: Validation error: Pipe operator detected in string literal

Expected

Pipes inside string literals should be allowed - they're not shell pipes, just characters.


Issue 3: capture() with pipes fails build

Code that fails (from examples/safety/injection_prevention.rs)

let count = capture("ls /tmp | wc -l");

Error

error: AST validation error: Unsupported expression type

Expected

The capture() function should handle commands with pipes since that's a common shell pattern.


Issue 4: Several examples don't build

$ bashrs build examples/basic/functions.rs -o /tmp/test.sh
error: AST validation error: Only functions are allowed in Rash code

The #[bashrs::main] attribute and #[cfg(test)] modules cause build failures.


Environment

  • bashrs version: 6.43.0
  • OS: Linux 6.8.0-87-generic

Suggested Improvements

  1. exec() should translate to eval or direct command execution, not shell exec
  2. String literal validation should not flag | inside quotes
  3. capture() should support piped commands
  4. Examples should all be buildable with bashrs build

Reproduction

#[bashrs::main]
fn main() {
    echo("|table|header|");  // Fails: pipe detected
    exec("ls -la");          // Wrong: generates shell exec
    let x = capture("ls | wc -l");  // Fails: unsupported
}

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions