php / php/doc-en

System call functions sometimes treat the last line in a multi-line command as a separate command

Open
#4,769 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

From manual page: https://php.net/function.exec


    function argon2idKey(string $password, string $salt): string
    {
        $innerCommand =
            'echo ' . escapeshellarg($password) . ' | \\' . "\n"
            . '  argon2 $(echo ' . escapeshellarg(base64_encode($salt)) . ' | base64 -d) -id -l 32 \\' . "\n"
            . '    -t 1 \\' . "\n"
            . '    -m 16 \\' . "\n"
            . '    -p 4 \\ ' . "\n"
            . '    -r';
        $command = 'bash -c ' . escapeshellarg($innerCommand);

        echo $command;

        return exec($command);
    }

The output contains "bash: line 6: -r: command not found". If the output of echo $command; is copied/pasted into the console and ran as-is, it will execute normally. If the -r argument is placed together with -p 4 becoming . ' -p 4 -r', exec() will execute the command with no issues.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with the linked exec() manual page and run the provided PHP/bash reproduction, comparing exec() with the interactive shell behavior. Done means the differing treatment of the final line is explained and the appropriate documentation or implementation follow-up is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, php
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.