[Solved] Why such output of "./fpc" lazarus / 62-General ---------------------------------------------------------------------- AlexTP · 2021-03-09 08:37 Quoteuser@PC:~/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux$ ./fpc Free Pascal Compiler version 3.2.1-r48494 [2021/02/02] for x86_64 Copyright (c) 1993-2020 by Florian Klaempfl and others /home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc [options] [options]  Only options valid for the default or selected platform are listed. I suggest not to print the enture path of 'fpc' binary here: Quote/home/user/fpcupdeluxe/fpcupdeluxe32/fpc/bin/x86_64-linux/fpc [options] [options] ---------------------------------------------------------------------- Jonas Maebe · 2021-03-09 10:25 It prints paramstr(0), which under Linux includes the full path if that's what you typed on the command line. It's also important, because an fpc binary in a different location may be a different version that supports different options. ---------------------------------------------------------------------- Warfley · 2021-03-09 16:48 Thats not quite right, this is FPC specific behavior and has nothing to do with Linux. On Linux usually the first argument (argv[0] in c, or $0 in bash) is the first argument given to the exec* call. In Bash this is exactly the path used in the command. The FPC however always compiles the code in a way that it will always return the absolute path (don't ask me why and how, I only observed this behavior from the outside). Example: test.c: Code: C  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i #include int main(int argc, char const * const *argv) {  printf("%s\n", argv[0]);  return 0;}test.sh: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i echo $0test.pas: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Test;{$Mode ObjFPC}{$H+} begin  WriteLn(ParamStr(0));end. Outputs: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i user@ubuntu:~$ test/ctesttest/ctestuser@ubuntu:~$ test/pastest/home/user/test/pastestuser@ubuntu:~$ bash test/test.shtest/test.shuser@ubuntu:~$ cd testuser@ubuntu:~/test$ ./ctest./ctestuser@ubuntu:~/test$ ./pastest/home/user/test/pastestuser@ubuntu:~/test$ bash ./test.sh./test.sh  For C cli applications it is common pratice for help pages to simply print argv[0] [options] as first line, something the FPC also does with ParamStr(0). The thing is that ParamStr behaves differently then most other languages. It should be noted that this means that information is actually lost, as you can see here: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i test@ubuntu:~$ test/../test/../test/ctesttest/../test/../test/ctestThe complete path information of the call is stored, even the redundant one. I don't know of any possibility to access this information from fpc programs ---------------------------------------------------------------------- MarkMLl · 2021-03-09 17:00 In any event, an inexperienced user shouldn't be messing around with a malformed command line. OTOH I think that complaining that FPC doesn't support the --version and --help commands would be fair criticism. MarkMLl ---------------------------------------------------------------------- trev · 2021-03-10 06:10 I didn't think using paramStr(0), or any function which uses it, on any UNIX or UNIX-like platform to determine the location of an executable was advised. ---------------------------------------------------------------------- lucamar · 2021-03-10 06:23 Quote from: trev on March 10, 2021, 07:10:01 amI didn't think using paramStr(0), or any function which uses it, on any UNIX or UNIX-like platform to determine the location of an executable was advised. It isn't, because it has many potential pitfalls. The RTL tries to overcome most of them (which is probably why it returns an absolute path no matter what) but they are there nevertheless. ---------------------------------------------------------------------- marcov · 2021-03-10 07:19 Did you try argv[0] ?