laravel / sail

Docker files for running a basic Laravel application.
https://laravel.com/docs/sail
MIT License
1.7k stars 477 forks source link

Pass all command line arguments to wrapped executable #728

Closed JoaquinTrinanes closed 2 months ago

JoaquinTrinanes commented 2 months ago

This PR makes sail <command> <args> always pass <args> to <command>.

Motivation

I found some discrepancies when using the tinker subcommand:

More specifically, my use case was to load a file that takes care of performing some initialization for me. Setting the current user, maybe assigning some variables that I'll need while testing things. But that doesn't work either:

echo '<?php throw new \Exception("File loaded");' > init.php

$ artisan tinker init.php
Psy Shell v0.12.3 (PHP 8.3.10 — cli) by Justin Hileman

   Exception  File loaded.

>

$ sail tinker init.php
Psy Shell v0.12.3 (PHP 8.3.10 — cli) by Justin Hileman
>

When looking at the sail script, I noticed that most commands forward $@, but tinker, mysql, mariadb, psql, redis, and open don't.

I believe this is confusing behavior, as it makes sail differ from how the actual underlying program works (like the tinker example). If a user passes an extra argument they probably do it for a reason, so with this change every argument is passed as-is.