If I create a file containing
and run it, I get no output. Running it manually in a terminal or
sourceing the script file does produce output.
history not work from a file?
The second command does "work", but the history is not enabled for non-interactive shells which is why it returns nothing in your script.