If I do this in a shell, I can see the !!
bash variable contains the last command.
$> echo foo
foo
$> echo !!
echo echo foo
echo foo
But this script
#!/bin/bash
mkdir /path/doesnt/exist ||
{
echo "Could not !!";
exit 1;
}
outputs
mkdir: cannot create directory ‘/path/doesnt/exist’: No such file or directory
Could not !!
I expected the output to be Could not mkdir /path/doesnt/exist
Why doesn't this work and how can I fix it?