Skip to content

Instantly share code, notes, and snippets.

View MatejKafka's full-sized avatar

Matěj Kafka MatejKafka

  • Prague, Czech Republic
  • 09:10 (UTC +02:00)
View GitHub Profile
@MatejKafka
MatejKafka / env.ps1
Created February 7, 2023 16:07
`fish`-style `env` command, which invokes a command with extra environment variables set
# Example: env TEST=1 cmd /c 'echo TEST=%TEST%'
function Invoke-WithEnvironment {
# parse arguments
$NewEnv = @{}
$CommandArgs = @()
$ParsingEnv = $true
foreach ($Arg in $Args) {
if ($ParsingEnv) {
# FIXME: is this pattern ok?
<?php
echo "test";
?>