I try to run Laravel's Artisan command inside the (docker) container by defining a doskey alias.
My idea was:
php artisan=docker-compose exec apache php artisan $1
However it does not allow me to use a space in the key. Any idea how to achieve this?
edit I have made a little GUI tool for Windows to run the commands https://github.com/thomasmoors/DockerArtisan
Answer
I must in this case give a negative answer - using blanks in a doskey name is impossible. Doskey was created for the Command Prompt (cmd), so is rather simple in concept.
This is impossible in my opinion since :
- In a doskey command such as
doskey a b=ab
, it takes "a" for an invalid option - The doskey command does not accept quotes around the macro name.
Here are some tests I have run :
As you can see, some special characters are accepted, but just not blanks.
Even without blanks in the macro name, doskey is an old DOS program and can only work in PowerShell with difficulty. It conflicts with the PSReadLine
module which relies on the native console input functions. I tested this :
As you can see, you need to do two additional actions :
- Issue the command
Remove-Module PSReadLine
- Add to the doskey command the parameter
/exename=powershell.exe
When both are done, the command is executed correctly and gives the right error.
My best advice is not to use doskey in PowerShell. Doskey is old and PowerShell is new, and they can only be used together with difficulty. I really don't think that doskey is so useful as to be irreplaceable.
Try to find another solution to your often-used commands. For example, store the commands in in executable files such as .ps1
or .cmd
or .bat
inside a folder that you would add to the PATH.
Comments
Post a Comment