Bug 13347 – rdmd: let args[0] be the .d file

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
tools
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-08-20T20:43:05Z
Last change time
2020-06-04T17:34:57Z
Assigned to
No Owner
Creator
Nils

Comments

Comment #0 by nilsbossung — 2014-08-20T20:43:05Z
When rdmd is used to sort-of interpret a .d file, it's actually compiled to a temporary executable and then run. As usual, args[0] is then the temporary executable. That path is next to useless, though. Other interpreters (bash, python, perl, php) pass the script file as args[0]. This allows to write scripts that act relative to the script file, no matter from where they were run. Would be nice if rdmd did that, too. This would be a breaking change, of course. But I can't imagine someone making use of the path to the temporary. --- cat > test.d << code import std.stdio; void main(string[] args) {writeln(args[0]);} code rdmd test.d --- /tmp/.rdmd-1000/rdmd-test.d-C7F94BC2B631D6BDE0380D58270F3E01/test --- Compare with bash, python, perl, php: --- echo 'echo $0' > test.sh bash test.sh echo 'print "$0\n"' > test.pl perl test.pl echo 'import sys; print sys.argv[0]' > test.py python test.py echo '<?php echo "{$argv[0]}\n";' > test.php php test.php --- test.sh test.pl test.py test.php ---
Comment #1 by pro.mathias.lang — 2020-06-04T17:34:57Z
Special-casing this for rdmd would be a bit awkward. However, we now have the token `__FILE_FULL_PATH__` which achieve what you want. Hence, closing this as WONTFIX.