Program name: Difference between revisions

This AWK solution is incorrect. (It reports the first file in the current directory, not the program file.) Instead just omit AWK.
mNo edit summary
(This AWK solution is incorrect. (It reports the first file in the current directory, not the program file.) Instead just omit AWK.)
Line 1:
{{task|Basic language learning}} [[Category:Initialization]]
The task is to programmatically obtain the name used to invoke the program. (For example determine whether the user ran "python hello.py", or "python hellocaller.py", a program importing the code from "hello.py".)
 
Line 5:
 
Examples from [https://github.com/mcandre/scriptname GitHub].
 
=={{header|AWK}}==
 
<lang awk>
BEGIN {
"ls" | getline file
close("ls")
print "This file is " file
}
</lang>
 
=={{header|AutoHotkey}}==
Line 701 ⟶ 691:
End If</lang>
 
{{omit from|AWK|With gawk, mawk, or nawk: ARGV[0] reports the name of the awk interpreter, not the name of the awk script. There is no variable nor shell command that provides the name of the awk script.}}
{{omit from|ZX Spectrum Basic}}
 
[[Category:Initialization]]
Anonymous user