Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Program-name/00-META.yaml
Normal file
5
Task/Program-name/00-META.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
category:
|
||||
- Initialization
|
||||
from: http://rosettacode.org/wiki/Program_name
|
||||
note: Basic language learning
|
||||
8
Task/Program-name/00-TASK.txt
Normal file
8
Task/Program-name/00-TASK.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
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".)
|
||||
|
||||
Sometimes a [[multiline shebang]] is necessary in order to provide the script name to a language's internal ARGV.
|
||||
|
||||
See also [[Command-line arguments]]
|
||||
|
||||
Examples from [https://github.com/mcandre/scriptname GitHub].
|
||||
|
||||
2
Task/Program-name/11l/program-name.11l
Normal file
2
Task/Program-name/11l/program-name.11l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
:start:
|
||||
print(‘Program: ’:argv[0])
|
||||
2
Task/Program-name/68000-Assembly/program-name.68000
Normal file
2
Task/Program-name/68000-Assembly/program-name.68000
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
LEA $000200,A3
|
||||
JSR PrintString ;(my print routine is 255-terminated and there just so happens to be an FF after the name of the game.)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
sp+0 = argc
|
||||
sp+8 = argv[0]
|
||||
sp+16 = argv[1] ...
|
||||
44
Task/Program-name/AArch64-Assembly/program-name-2.aarch64
Normal file
44
Task/Program-name/AArch64-Assembly/program-name-2.aarch64
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
.equ STDOUT, 1
|
||||
.equ SVC_WRITE, 64
|
||||
.equ SVC_EXIT, 93
|
||||
|
||||
.text
|
||||
.global _start
|
||||
|
||||
_start:
|
||||
stp x29, x30, [sp, -16]!
|
||||
mov x29, sp
|
||||
ldr x0, [sp, 24] // argv[0]
|
||||
bl _strlen // strlen(argv[0])
|
||||
mov x2, x0
|
||||
mov x0, #STDOUT
|
||||
ldr x1, [sp, 24]
|
||||
bl _write // write(stdout, argv[0], strlen(argv[0]))
|
||||
ldp x29, x30, [sp], 16
|
||||
mov x0, #0
|
||||
b _exit // exit(0);
|
||||
|
||||
// ssize_t _strlen(const char *str)
|
||||
_strlen:
|
||||
mov x1, x0
|
||||
mov x0, #-1
|
||||
1: add x0, x0, #1
|
||||
ldrb w2, [x1, x0]
|
||||
cbnz x2, 1b
|
||||
ret
|
||||
|
||||
.text
|
||||
//////////////// system call wrappers
|
||||
// ssize_t _write(int fd, void *buf, size_t count)
|
||||
_write:
|
||||
stp x29, x30, [sp, -16]!
|
||||
mov x8, #SVC_WRITE
|
||||
mov x29, sp
|
||||
svc #0
|
||||
ldp x29, x30, [sp], 16
|
||||
ret
|
||||
|
||||
// void _exit(int retval)
|
||||
_exit:
|
||||
mov x8, #SVC_EXIT
|
||||
svc #0
|
||||
3
Task/Program-name/ALGOL-68/program-name.alg
Normal file
3
Task/Program-name/ALGOL-68/program-name.alg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
BEGIN
|
||||
print ((program idf, newline))
|
||||
END
|
||||
54
Task/Program-name/ARM-Assembly/program-name.arm
Normal file
54
Task/Program-name/ARM-Assembly/program-name.arm
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program namepgm.s */
|
||||
/* Constantes */
|
||||
.equ STDOUT, 1
|
||||
.equ WRITE, 4
|
||||
.equ EXIT, 1
|
||||
/* Initialized data */
|
||||
.data
|
||||
szMessage: .asciz "Program : " @
|
||||
szRetourLigne: .asciz "\n"
|
||||
|
||||
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
push {fp,lr} /* save des 2 registres */
|
||||
add fp,sp,#8 /* fp <- adresse début */
|
||||
ldr r0, iAdrszMessage @ adresse of message
|
||||
bl affichageMess @ call function
|
||||
ldr r0,[fp,#4] @ recup name of program in command line
|
||||
bl affichageMess @ call function
|
||||
ldr r0, iAdrszRetourLigne @ adresse of message
|
||||
bl affichageMess @ call function
|
||||
|
||||
/* fin standard du programme */
|
||||
mov r0, #0 @ return code
|
||||
pop {fp,lr} @restaur des 2 registres
|
||||
mov r7, #EXIT @ request to exit program
|
||||
swi 0 @ perform the system call
|
||||
iAdrszMessage: .int szMessage
|
||||
iAdrszRetourLigne: .int szRetourLigne
|
||||
/******************************************************************/
|
||||
/* affichage des messages avec calcul longueur */
|
||||
/******************************************************************/
|
||||
/* r0 contient l adresse du message */
|
||||
affichageMess:
|
||||
push {fp,lr} /* save des 2 registres */
|
||||
push {r0,r1,r2,r7} /* save des autres registres */
|
||||
mov r2,#0 /* compteur longueur */
|
||||
1: /*calcul de la longueur */
|
||||
ldrb r1,[r0,r2] /* recup octet position debut + indice */
|
||||
cmp r1,#0 /* si 0 c est fini */
|
||||
beq 1f
|
||||
add r2,r2,#1 /* sinon on ajoute 1 */
|
||||
b 1b
|
||||
1: /* donc ici r2 contient la longueur du message */
|
||||
mov r1,r0 /* adresse du message en r1 */
|
||||
mov r0,#STDOUT /* code pour écrire sur la sortie standard Linux */
|
||||
mov r7, #WRITE /* code de l appel systeme "write" */
|
||||
swi #0 /* appel systeme */
|
||||
pop {r0,r1,r2,r7} /* restaur des autres registres */
|
||||
pop {fp,lr} /* restaur des 2 registres */
|
||||
bx lr /* retour procedure */
|
||||
|
||||
18
Task/Program-name/AWK/program-name.awk
Normal file
18
Task/Program-name/AWK/program-name.awk
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# syntax: TAWK -f PROGRAM_NAME.AWK
|
||||
#
|
||||
# GAWK can provide the invoking program name from ARGV[0] but is unable to
|
||||
# provide the AWK script name that follows -f. Thompson Automation's TAWK
|
||||
# version 5.0c, last released in 1998 and no longer commercially available, can
|
||||
# provide the AWK script name that follows -f from the PROGFN built-in
|
||||
# variable. It should also provide the invoking program name, E.G. TAWK, from
|
||||
# ARGV[0] but due to a bug it holds the fully qualified -f name instead.
|
||||
#
|
||||
# This example is posted here with hopes the TAWK built-in variables PROGFN
|
||||
# (PROGram File Name) and PROGLN (PROGram Line Number) be added to GAWK by its
|
||||
# developers.
|
||||
#
|
||||
BEGIN {
|
||||
printf("%s -f %s\n",ARGV[0],PROGFN)
|
||||
printf("line number %d\n",PROGLN)
|
||||
exit(0)
|
||||
}
|
||||
6
Task/Program-name/Ada/program-name.ada
Normal file
6
Task/Program-name/Ada/program-name.ada
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
with Ada.Command_Line, Ada.Text_IO;
|
||||
|
||||
procedure Command_Name is
|
||||
begin
|
||||
Ada.Text_IO.Put_Line(Ada.Command_Line.Command_Name);
|
||||
end Command_Name;
|
||||
2
Task/Program-name/Aime/program-name.aime
Normal file
2
Task/Program-name/Aime/program-name.aime
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
o_text(argv(0));
|
||||
o_byte('\n');
|
||||
5
Task/Program-name/Amazing-Hopper/program-name.hopper
Normal file
5
Task/Program-name/Amazing-Hopper/program-name.hopper
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#include <hbasic.h>
|
||||
Begin
|
||||
GetParam(name File)
|
||||
Print("My Program name: ", name File,Newl)
|
||||
End
|
||||
61
Task/Program-name/Applesoft-BASIC/program-name.basic
Normal file
61
Task/Program-name/Applesoft-BASIC/program-name.basic
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
10 GOSUB 40"GET PROGRAM NAME
|
||||
20 PRINT N$
|
||||
30 END
|
||||
|
||||
40 REMGET PROGRAM NAME
|
||||
50 GOSUB 100"GET INPUT BUFFER
|
||||
60 GOSUB 200"REMOVE RUN PREFIX
|
||||
70 GOSUB 300"REMOVE , SUFFIXES
|
||||
80 GOSUB 400"TRIM SPACES
|
||||
90 RETURN
|
||||
|
||||
100 REMGET INPUT BUFFER
|
||||
110 N$ = ""
|
||||
120 FOR I = 512 TO 767
|
||||
130 B = PEEK (I) - 128
|
||||
140 IF B < 32 THEN RETURN
|
||||
150 N$ = N$ + CHR$ (B)
|
||||
160 NEXT I
|
||||
170 RETURN
|
||||
|
||||
200 REMREMOVE RUN PREFIX
|
||||
210 P = 1
|
||||
220 FOR I = 1 TO 3
|
||||
230 FOR J = P TO LEN(N$)
|
||||
240 C$ = MID$ (N$,J,1)
|
||||
250 P = P + 1
|
||||
260 IF C$ = " " THEN NEXT J
|
||||
270 IF C$ = MID$("RUN",I,1) THEN NEXT I:N$ = MID$(N$,P,LEN(N$)-P+1):RETURN
|
||||
280 PRINT "YOU NEED TO RUN THIS PROGRAM USING THE RUN COMMAND FROM DOS."
|
||||
290 END
|
||||
|
||||
300 REMREMOVE , SUFFIXES
|
||||
310 L = LEN (N$)
|
||||
320 FOR I = 1 TO L
|
||||
330 C$ = MID$ (N$,I,1)
|
||||
340 IF C$ = "," THEN N$ = LEFT$(N$,I - 1): RETURN
|
||||
350 NEXT I
|
||||
360 RETURN
|
||||
|
||||
400 REMTRIM SPACES
|
||||
410 GOSUB 600
|
||||
|
||||
500 REMLEFT TRIM SPACES
|
||||
510 L = LEN(N$) - 1
|
||||
520 FOR I = L TO 0 STEP -1
|
||||
530 IF I < 0 THEN RETURN
|
||||
540 IF LEFT$ (N$,1) <> " " THEN RETURN
|
||||
550 IF I THEN N$ = RIGHT$ (N$, I)
|
||||
560 NEXT I
|
||||
570 N$ = "
|
||||
580 RETURN
|
||||
|
||||
600 REMRIGHT TRIM SPACES
|
||||
610 L = LEN(N$) - 1
|
||||
620 FOR I = L TO 0 STEP -1
|
||||
630 IF I < 0 THEN RETURN
|
||||
640 IF RIGHT$ (N$,1) <> " " THEN RETURN
|
||||
650 IF I THEN N$ = LEFT$ (N$, I)
|
||||
660 NEXT I
|
||||
670 N$ = "
|
||||
680 RETURN
|
||||
1
Task/Program-name/AutoHotkey/program-name.ahk
Normal file
1
Task/Program-name/AutoHotkey/program-name.ahk
Normal file
|
|
@ -0,0 +1 @@
|
|||
MsgBox, % A_ScriptName
|
||||
2
Task/Program-name/BBC-BASIC/program-name.basic
Normal file
2
Task/Program-name/BBC-BASIC/program-name.basic
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
SYS "GetCommandLine" TO cl%
|
||||
PRINT $$cl%
|
||||
1
Task/Program-name/BaCon/program-name-1.bacon
Normal file
1
Task/Program-name/BaCon/program-name-1.bacon
Normal file
|
|
@ -0,0 +1 @@
|
|||
PRINT TOKEN$(ARGUMENT$, 1)
|
||||
1
Task/Program-name/BaCon/program-name-2.bacon
Normal file
1
Task/Program-name/BaCon/program-name-2.bacon
Normal file
|
|
@ -0,0 +1 @@
|
|||
PRINT ME$
|
||||
25
Task/Program-name/Blue/program-name.blue
Normal file
25
Task/Program-name/Blue/program-name.blue
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
global _start
|
||||
|
||||
: syscall ( num:eax -- result:eax ) syscall ;
|
||||
|
||||
: exit ( status:edi -- noret ) 60 syscall ;
|
||||
: bye ( -- noret ) 0 exit ;
|
||||
|
||||
: write ( buf:esi len:edx fd:edi -- ) 1 syscall drop ;
|
||||
|
||||
1 const stdout
|
||||
|
||||
: print ( buf len -- ) stdout write ;
|
||||
|
||||
: newline ( -- ) s" \n" print ;
|
||||
: println ( buf len -- ) print newline ;
|
||||
|
||||
: find0 ( start:rsi -- end:rsi ) lodsb 0 cmp latest xne ;
|
||||
: cstrlen ( str:rdi -- len:rsi ) dup find0 swap sub dec ;
|
||||
: cstr>str ( cstr:rdx -- str:rsi len:rdx ) dup cstrlen xchg ;
|
||||
|
||||
: print-arg ( arg -- ) cstr>str println ;
|
||||
|
||||
: arg0 ( rsp -- rsp ) 8 add @ ; inline
|
||||
|
||||
: _start ( rsp -- noret ) arg0 print-arg bye ;
|
||||
8
Task/Program-name/C++/program-name.cpp
Normal file
8
Task/Program-name/C++/program-name.cpp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char *program = argv[0];
|
||||
cout << "Program: " << program << endl;
|
||||
}
|
||||
11
Task/Program-name/C-sharp/program-name-1.cs
Normal file
11
Task/Program-name/C-sharp/program-name-1.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
namespace ProgramName
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.Write(Environment.CommandLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Task/Program-name/C-sharp/program-name-2.cs
Normal file
19
Task/Program-name/C-sharp/program-name-2.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
namespace ProgramName
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// Extracts the filename from the full path
|
||||
System.IO.FileInfo exeInfo = new System.IO.FileInfo(System.Windows.Forms.Application.ExecutablePath);
|
||||
Console.Write(exeInfo.Name);
|
||||
|
||||
// Writes all arguments to the console
|
||||
foreach (string argument in args)
|
||||
{
|
||||
Console.Write(" " + argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Task/Program-name/C/program-name-1.c
Normal file
7
Task/Program-name/C/program-name-1.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
printf("Executable: %s\n", argv[0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
8
Task/Program-name/C/program-name-2.c
Normal file
8
Task/Program-name/C/program-name-2.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("This code was in file %s in function %s, at line %d\n",\
|
||||
__FILE__, __FUNCTION__, __LINE__);
|
||||
return 0;
|
||||
}
|
||||
37
Task/Program-name/C/program-name-3.c
Normal file
37
Task/Program-name/C/program-name-3.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* myname.c */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h> /* struct kinfo_proc */
|
||||
#include <err.h>
|
||||
#include <fcntl.h> /* O_RDONLY */
|
||||
#include <kvm.h>
|
||||
#include <limits.h> /* _POSIX2_LINE_MAX */
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
extern char *__progname; /* from crt0.o */
|
||||
|
||||
struct kinfo_proc *procs;
|
||||
kvm_t *kd;
|
||||
int cnt;
|
||||
char errbuf[_POSIX2_LINE_MAX];
|
||||
|
||||
printf("argv[0]: %s\n", argv[0]);
|
||||
printf("__progname: %s\n", __progname);
|
||||
|
||||
kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
|
||||
if (kd == NULL)
|
||||
errx(1, "%s", errbuf);
|
||||
procs = kvm_getprocs(kd, KERN_PROC_PID, getpid(),
|
||||
sizeof procs[0], &cnt);
|
||||
if (procs == NULL)
|
||||
errx(1, "%s", kvm_geterr(kd));
|
||||
if (cnt != 1)
|
||||
errx(1, "impossible");
|
||||
|
||||
printf("p_comm: %s\n", procs[0].p_comm);
|
||||
|
||||
kvm_close(kd);
|
||||
return 0;
|
||||
}
|
||||
57
Task/Program-name/C/program-name-4.c
Normal file
57
Task/Program-name/C/program-name-4.c
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
|
||||
/*
|
||||
* Returns the path to the current executable file, in a newly
|
||||
* allocated buffer. Use free() to free it.
|
||||
*/
|
||||
wchar_t *
|
||||
exepath(void)
|
||||
{
|
||||
wchar_t *buf, *newbuf;
|
||||
long blen, flen;
|
||||
|
||||
/*
|
||||
* Most paths fit in MAX_PATH == 260 characters, but very
|
||||
* long UNC paths might require a larger buffer.
|
||||
*/
|
||||
buf = NULL;
|
||||
for (blen = MAX_PATH; 1; blen += MAX_PATH) {
|
||||
/* Enlarge buffer. */
|
||||
newbuf = realloc(buf, blen * sizeof buf[0]);
|
||||
if (newbuf == NULL) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
buf = newbuf;
|
||||
|
||||
flen = GetModuleFileNameW(NULL, buf, blen);
|
||||
if (flen == 0) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
if (flen < blen)
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the path to this executable.
|
||||
*/
|
||||
int
|
||||
main()
|
||||
{
|
||||
wchar_t *path;
|
||||
|
||||
path = exepath();
|
||||
if (path == NULL) {
|
||||
wprintf(L"Sorry, an error occured.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
wprintf(L"Path to executable: %ls\n", path);
|
||||
|
||||
free(path);
|
||||
return 0;
|
||||
}
|
||||
18
Task/Program-name/COBOL/program-name.cobol
Normal file
18
Task/Program-name/COBOL/program-name.cobol
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
identification division.
|
||||
program-id. sample.
|
||||
|
||||
data division.
|
||||
working-storage section.
|
||||
01 progname pic x(16).
|
||||
|
||||
procedure division.
|
||||
sample-main.
|
||||
|
||||
display 0 upon argument-number
|
||||
accept progname from argument-value
|
||||
display "argument-value zero :" progname ":"
|
||||
|
||||
display "function module-id :" function module-id ":"
|
||||
|
||||
goback.
|
||||
end program sample.
|
||||
12
Task/Program-name/Clojure/program-name.clj
Normal file
12
Task/Program-name/Clojure/program-name.clj
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
":";exec lein exec $0 ${1+"$@"}
|
||||
":";exit
|
||||
|
||||
(ns scriptname
|
||||
(:gen-class))
|
||||
|
||||
(defn -main [& args]
|
||||
(let [program (first *command-line-args*)]
|
||||
(println "Program:" program)))
|
||||
|
||||
(when (.contains (first *command-line-args*) *source-path*)
|
||||
(apply -main (rest *command-line-args*)))
|
||||
7
Task/Program-name/CoffeeScript/program-name.coffee
Normal file
7
Task/Program-name/CoffeeScript/program-name.coffee
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env coffee
|
||||
|
||||
main = () ->
|
||||
program = __filename
|
||||
console.log "Program: " + program
|
||||
|
||||
if not module.parent then main()
|
||||
6
Task/Program-name/Common-Lisp/program-name-1.lisp
Normal file
6
Task/Program-name/Common-Lisp/program-name-1.lisp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
;;; Play nice with shebangs
|
||||
(set-dispatch-macro-character #\# #\!
|
||||
(lambda (stream character n)
|
||||
(declare (ignore character n))
|
||||
(read-line stream nil nil t)
|
||||
nil))
|
||||
30
Task/Program-name/Common-Lisp/program-name-2.lisp
Normal file
30
Task/Program-name/Common-Lisp/program-name-2.lisp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
#|
|
||||
exec clisp -q -q $0 $0 ${1+"$@"}
|
||||
exit
|
||||
|#
|
||||
|
||||
;;; Usage: ./scriptname.lisp
|
||||
|
||||
(defun main (args)
|
||||
(let ((program (car args)))
|
||||
(format t "Program: ~a~%" program)
|
||||
(quit)))
|
||||
|
||||
;;; With help from Francois-Rene Rideau
|
||||
;;; http://tinyurl.com/cli-args
|
||||
(let ((args
|
||||
#+clisp (ext:argv)
|
||||
#+sbcl sb-ext:*posix-argv*
|
||||
#+clozure (ccl::command-line-arguments)
|
||||
#+gcl si:*command-args*
|
||||
#+ecl (loop for i from 0 below (si:argc) collect (si:argv i))
|
||||
#+cmu extensions:*command-line-strings*
|
||||
#+allegro (sys:command-line-arguments)
|
||||
#+lispworks sys:*line-arguments-list*
|
||||
))
|
||||
|
||||
(if (member (pathname-name *load-truename*)
|
||||
args
|
||||
:test #'(lambda (x y) (search x y :test #'equalp)))
|
||||
(main args)))
|
||||
7
Task/Program-name/D/program-name-1.d
Normal file
7
Task/Program-name/D/program-name-1.d
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env rdmd
|
||||
|
||||
import std.stdio;
|
||||
|
||||
void main(in string[] args) {
|
||||
writeln("Program: ", args[0]);
|
||||
}
|
||||
3
Task/Program-name/D/program-name-2.d
Normal file
3
Task/Program-name/D/program-name-2.d
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
$ dmd scriptname.d
|
||||
$ ./scriptname
|
||||
Program: ./scriptname
|
||||
2
Task/Program-name/D/program-name-3.d
Normal file
2
Task/Program-name/D/program-name-3.d
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ ./scriptname.d
|
||||
Program: /tmp/.rdmd/Users/andrew/Desktop/src/scriptname/scriptname.d.D3B32385A31B968A3CF8CAF1E1426E5F
|
||||
9
Task/Program-name/D/program-name-4.d
Normal file
9
Task/Program-name/D/program-name-4.d
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// thisExePath function was introduced in D 2.064 (November 5, 2013)
|
||||
|
||||
import std.file;
|
||||
import std.stdio;
|
||||
|
||||
void main(string[] args)
|
||||
{
|
||||
writeln("Program: ", thisExePath());
|
||||
}
|
||||
6
Task/Program-name/Dart/program-name.dart
Normal file
6
Task/Program-name/Dart/program-name.dart
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env dart
|
||||
|
||||
main() {
|
||||
var program = new Options().script;
|
||||
print("Program: ${program}");
|
||||
}
|
||||
8
Task/Program-name/Delphi/program-name.delphi
Normal file
8
Task/Program-name/Delphi/program-name.delphi
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
program ProgramName;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
begin
|
||||
Writeln('Program name: ' + ParamStr(0));
|
||||
Writeln('Command line: ' + CmdLine);
|
||||
end.
|
||||
3
Task/Program-name/EMal/program-name.emal
Normal file
3
Task/Program-name/EMal/program-name.emal
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
writeLine("path: " + Runtime.path)
|
||||
writeLine("name: " + Runtime.name)
|
||||
writeLine("args: " + Runtime.args)
|
||||
2
Task/Program-name/EchoLisp/program-name.l
Normal file
2
Task/Program-name/EchoLisp/program-name.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(js-eval "window.location.href")
|
||||
→ "http://www.echolalie.org/echolisp/"
|
||||
8
Task/Program-name/Elena/program-name.elena
Normal file
8
Task/Program-name/Elena/program-name.elena
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import extensions;
|
||||
|
||||
public program()
|
||||
{
|
||||
console.printLine(program_arguments.asEnumerable()); // the whole command line
|
||||
|
||||
console.printLine(program_arguments[0]); // the program name
|
||||
}
|
||||
8
Task/Program-name/Emacs-Lisp/program-name.l
Normal file
8
Task/Program-name/Emacs-Lisp/program-name.l
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
:;exec emacs -batch -l $0 -f main $*
|
||||
|
||||
;;; Shebang from John Swaby
|
||||
;;; http://www.emacswiki.org/emacs/EmacsScripts
|
||||
|
||||
(defun main ()
|
||||
(let ((program (nth 2 command-line-args)))
|
||||
(message "Program: %s" program)))
|
||||
15
Task/Program-name/Erlang/program-name.erl
Normal file
15
Task/Program-name/Erlang/program-name.erl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
%% Compile
|
||||
%%
|
||||
%% erlc scriptname.erl
|
||||
%%
|
||||
%% Run
|
||||
%%
|
||||
%% erl -noshell -s scriptname
|
||||
|
||||
-module(scriptname).
|
||||
-export([start/0]).
|
||||
|
||||
start() ->
|
||||
Program = ?FILE,
|
||||
io:format("Program: ~s~n", [Program]),
|
||||
init:stop().
|
||||
2
Task/Program-name/Euphoria/program-name.euphoria
Normal file
2
Task/Program-name/Euphoria/program-name.euphoria
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
constant cmd = command_line()
|
||||
puts(1,cmd[2])
|
||||
20
Task/Program-name/F-Sharp/program-name.fs
Normal file
20
Task/Program-name/F-Sharp/program-name.fs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#light (*
|
||||
exec fsharpi --exec $0 --quiet
|
||||
*)
|
||||
|
||||
let scriptname =
|
||||
let args = System.Environment.GetCommandLineArgs()
|
||||
|
||||
let arg0 = args.[0]
|
||||
|
||||
if arg0.Contains("fsi") then
|
||||
let arg1 = args.[1]
|
||||
if arg1 = "--exec" then
|
||||
args.[2]
|
||||
else
|
||||
arg1
|
||||
else
|
||||
arg0
|
||||
|
||||
let main =
|
||||
printfn "%s" scriptname
|
||||
8
Task/Program-name/Factor/program-name.factor
Normal file
8
Task/Program-name/Factor/program-name.factor
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#! /usr/bin/env factor
|
||||
|
||||
USING: namespaces io command-line ;
|
||||
IN: scriptname
|
||||
|
||||
: main ( -- ) script get print ;
|
||||
|
||||
MAIN: main
|
||||
2
Task/Program-name/Forth/program-name.fth
Normal file
2
Task/Program-name/Forth/program-name.fth
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
0 arg type cr \ gforth or gforth-fast, for example
|
||||
1 arg type cr \ name of script
|
||||
47
Task/Program-name/Fortran/program-name.f
Normal file
47
Task/Program-name/Fortran/program-name.f
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
! program run with invalid name path/f
|
||||
!
|
||||
!-*- mode: compilation; default-directory: "/tmp/" -*-
|
||||
!Compilation started at Sun Jun 2 00:18:31
|
||||
!
|
||||
!a=./f && make $a && OMP_NUM_THREADS=2 $a < unixdict.txt
|
||||
!gfortran -std=f2008 -Wall -fopenmp -ffree-form -fall-intrinsics -fimplicit-none f.f08 -o f
|
||||
!
|
||||
!Compilation finished at Sun Jun 2 00:18:31
|
||||
|
||||
|
||||
|
||||
! program run with valid name path/rcname
|
||||
!
|
||||
!-*- mode: compilation; default-directory: "/tmp/" -*-
|
||||
!Compilation started at Sun Jun 2 00:19:01
|
||||
!
|
||||
!gfortran -std=f2008 -Wall -fopenmp -ffree-form -fall-intrinsics -fimplicit-none f.f08 -o rcname && ./rcname
|
||||
! ./rcname approved.
|
||||
! program continues...
|
||||
!
|
||||
!Compilation finished at Sun Jun 2 00:19:02
|
||||
|
||||
|
||||
module sundry
|
||||
|
||||
contains
|
||||
|
||||
subroutine verify_name(required)
|
||||
! name verification reduces the ways an attacker can rename rm as cp.
|
||||
character(len=*), intent(in) :: required
|
||||
character(len=1024) :: name
|
||||
integer :: length, status
|
||||
! I believe get_command_argument is part of the 2003 FORTRAN standard intrinsics.
|
||||
call get_command_argument(0, name, length, status)
|
||||
if (0 /= status) stop
|
||||
if ((len_trim(name)+1) .ne. (index(name, required, back=.true.) + len(required))) stop
|
||||
write(6,*) trim(name)//' approved.'
|
||||
end subroutine verify_name
|
||||
|
||||
end module sundry
|
||||
|
||||
program name
|
||||
use sundry
|
||||
call verify_name('rcname')
|
||||
write(6,*)'program continues...'
|
||||
end program name
|
||||
1
Task/Program-name/FreeBASIC/program-name-1.basic
Normal file
1
Task/Program-name/FreeBASIC/program-name-1.basic
Normal file
|
|
@ -0,0 +1 @@
|
|||
appname = COMMAND$(0)
|
||||
1
Task/Program-name/FreeBASIC/program-name-2.basic
Normal file
1
Task/Program-name/FreeBASIC/program-name-2.basic
Normal file
|
|
@ -0,0 +1 @@
|
|||
appname = *__FB_ARGV__(0)
|
||||
5
Task/Program-name/FreeBASIC/program-name.basic
Normal file
5
Task/Program-name/FreeBASIC/program-name.basic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Print "The program was invoked like this => "; Command(0) + " " + Command(-1)
|
||||
Print "Press any key to quit"
|
||||
Sleep
|
||||
2
Task/Program-name/FutureBasic/program-name.basic
Normal file
2
Task/Program-name/FutureBasic/program-name.basic
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print fn ProcessInfoProcessName
|
||||
print fn RunningApplicationLocalizedName( fn RunningApplicationCurrentApplication )
|
||||
10
Task/Program-name/Gambas/program-name.gambas
Normal file
10
Task/Program-name/Gambas/program-name.gambas
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
Public Sub Main()
|
||||
Dim sTemp As String
|
||||
|
||||
Print "Command to start the program was ";;
|
||||
|
||||
For Each sTemp In Args.All
|
||||
Print sTemp;;
|
||||
Next
|
||||
|
||||
End
|
||||
6
Task/Program-name/Genie/program-name.genie
Normal file
6
Task/Program-name/Genie/program-name.genie
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[indent=4]
|
||||
init
|
||||
print args[0]
|
||||
print Path.get_basename(args[0])
|
||||
print Environment.get_application_name()
|
||||
print Environment.get_prgname()
|
||||
10
Task/Program-name/Go/program-name.go
Normal file
10
Task/Program-name/Go/program-name.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Program:", os.Args[0])
|
||||
}
|
||||
5
Task/Program-name/Groovy/program-name-1.groovy
Normal file
5
Task/Program-name/Groovy/program-name-1.groovy
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env groovy
|
||||
|
||||
def program = getClass().protectionDomain.codeSource.location.path
|
||||
|
||||
println "Program: " + program
|
||||
1
Task/Program-name/Groovy/program-name-2.groovy
Normal file
1
Task/Program-name/Groovy/program-name-2.groovy
Normal file
|
|
@ -0,0 +1 @@
|
|||
println this.class.getName()
|
||||
4
Task/Program-name/Haskell/program-name.hs
Normal file
4
Task/Program-name/Haskell/program-name.hs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import System (getProgName)
|
||||
|
||||
main :: IO ()
|
||||
main = getProgName >>= putStrLn . ("Program: " ++)
|
||||
9
Task/Program-name/IS-BASIC/program-name.basic
Normal file
9
Task/Program-name/IS-BASIC/program-name.basic
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
100 PROGRAM "Name1.bas"(A,B,C,S$)
|
||||
110 CHAIN "Name2.BAS"(A,B,C,S$)
|
||||
|
||||
edit 1
|
||||
100 PROGRAM "Name2.bas"(A,B,C,S$)
|
||||
110 PRINT A,B,C,S$
|
||||
|
||||
edit 0
|
||||
start(1,2,3,"Hello")
|
||||
3
Task/Program-name/Icon/program-name.icon
Normal file
3
Task/Program-name/Icon/program-name.icon
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
procedure main()
|
||||
write(&progname) # obtain and write out the program name from the keyword &progname
|
||||
end
|
||||
9
Task/Program-name/Io/program-name.io
Normal file
9
Task/Program-name/Io/program-name.io
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env io
|
||||
|
||||
main := method(
|
||||
program := System args at(0)
|
||||
|
||||
("Program: " .. program) println
|
||||
)
|
||||
|
||||
if (System args size > 0 and System args at(0) containsSeq("scriptname"), main)
|
||||
13
Task/Program-name/J/program-name.j
Normal file
13
Task/Program-name/J/program-name.j
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env jconsole
|
||||
|
||||
program =: monad : 0
|
||||
if. (#ARGV) > 1 do.
|
||||
> 1 { ARGV
|
||||
else.
|
||||
'Interpreted'
|
||||
end.
|
||||
)
|
||||
|
||||
echo 'Program: ', program 0
|
||||
|
||||
exit ''
|
||||
4
Task/Program-name/Jakt/program-name.jakt
Normal file
4
Task/Program-name/Jakt/program-name.jakt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
fn main(arguments: [String]) {
|
||||
let program_name = arguments[0]
|
||||
println("{}", program_name)
|
||||
}
|
||||
6
Task/Program-name/Java/program-name-1.java
Normal file
6
Task/Program-name/Java/program-name-1.java
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
public class ScriptName {
|
||||
public static void main(String[] args) {
|
||||
String program = System.getProperty("sun.java.command").split(" ")[0];
|
||||
System.out.println("Program: " + program);
|
||||
}
|
||||
}
|
||||
6
Task/Program-name/Java/program-name-2.java
Normal file
6
Task/Program-name/Java/program-name-2.java
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
public class ScriptName {
|
||||
public static void main(String[] args) {
|
||||
Class c = new Object(){}.getClass().getEnclosingClass();
|
||||
System.out.println("Program: " + c.getName());
|
||||
}
|
||||
}
|
||||
6
Task/Program-name/Java/program-name-3.java
Normal file
6
Task/Program-name/Java/program-name-3.java
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
public class ScriptName {
|
||||
public static void main(String[] args) {
|
||||
Class c = System.getSecurityManager().getClassContext()[0];
|
||||
System.out.println("Program: " + c.getName());
|
||||
}
|
||||
}
|
||||
6
Task/Program-name/Java/program-name-4.java
Normal file
6
Task/Program-name/Java/program-name-4.java
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
public class ScriptName {
|
||||
public static void main(String[] args) {
|
||||
String program = Thread.currentThread().getStackTrace()[1].getClassName();
|
||||
System.out.println("Program: " + program);
|
||||
}
|
||||
}
|
||||
3
Task/Program-name/JavaScript/program-name-1.js
Normal file
3
Task/Program-name/JavaScript/program-name-1.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function foo() {
|
||||
return arguments.callee.name;
|
||||
}
|
||||
1
Task/Program-name/JavaScript/program-name-2.js
Normal file
1
Task/Program-name/JavaScript/program-name-2.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
(function(){alert(arguments.callee.name);}())
|
||||
9
Task/Program-name/JavaScript/program-name-3.js
Normal file
9
Task/Program-name/JavaScript/program-name-3.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env node
|
||||
/*jslint nodejs:true */
|
||||
|
||||
function main() {
|
||||
var program = __filename;
|
||||
console.log("Program: " + program);
|
||||
}
|
||||
|
||||
if (!module.parent) { main(); }
|
||||
3
Task/Program-name/Joy/program-name.joy
Normal file
3
Task/Program-name/Joy/program-name.joy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/joy
|
||||
|
||||
argv first putchars.
|
||||
4
Task/Program-name/Jsish/program-name.jsish
Normal file
4
Task/Program-name/Jsish/program-name.jsish
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env jsish
|
||||
/* Program name, in Jsish */
|
||||
puts('Executable:', Info.executable());
|
||||
puts('Argv0 :', Info.argv0());
|
||||
2
Task/Program-name/Julia/program-name.julia
Normal file
2
Task/Program-name/Julia/program-name.julia
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
prog = basename(Base.source_path())
|
||||
println("This program file is \"", prog, "\".")
|
||||
8
Task/Program-name/Kotlin/program-name.kotlin
Normal file
8
Task/Program-name/Kotlin/program-name.kotlin
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// version 1.0.6
|
||||
|
||||
// 'progname.kt' packaged as 'progname.jar'
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(System.getProperty("sun.java.command")) // may not exist on all JVMs
|
||||
println(System.getProperty("java.vm.name"))
|
||||
}
|
||||
6
Task/Program-name/LLVM/program-name-1.llvm
Normal file
6
Task/Program-name/LLVM/program-name-1.llvm
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
$ make
|
||||
llvm-as scriptname.ll
|
||||
llc -disable-cfi scriptname.bc
|
||||
gcc -o scriptname scriptname.s
|
||||
./scriptname
|
||||
Program: ./scriptname
|
||||
10
Task/Program-name/LLVM/program-name-2.llvm
Normal file
10
Task/Program-name/LLVM/program-name-2.llvm
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
all: scriptname.ll
|
||||
llvm-as scriptname.ll
|
||||
llc scriptname.bc
|
||||
gcc -o scriptname scriptname.s
|
||||
./scriptname
|
||||
|
||||
clean:
|
||||
-rm scriptname
|
||||
-rm scriptname.s
|
||||
-rm scriptname.bc
|
||||
10
Task/Program-name/LLVM/program-name-3.llvm
Normal file
10
Task/Program-name/LLVM/program-name-3.llvm
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
@msg_main = internal constant [13 x i8] c"Program: %s\0A\00"
|
||||
|
||||
declare i32 @printf(i8* noalias nocapture, ...)
|
||||
|
||||
define i32 @main(i32 %argc, i8** %argv) {
|
||||
%program = load i8** %argv
|
||||
call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([13 x i8]* @msg_main, i32 0, i32 0), i8* %program)
|
||||
|
||||
ret i32 0
|
||||
}
|
||||
2
Task/Program-name/Langur/program-name.langur
Normal file
2
Task/Program-name/Langur/program-name.langur
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
writeln "script: ", _script
|
||||
writeln "script args: ", _args
|
||||
3
Task/Program-name/Lasso/program-name-1.lasso
Normal file
3
Task/Program-name/Lasso/program-name-1.lasso
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/lasso9
|
||||
|
||||
stdoutnl("Program: " + $argv->first)
|
||||
2
Task/Program-name/Lasso/program-name-2.lasso
Normal file
2
Task/Program-name/Lasso/program-name-2.lasso
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$ lasso9 script_name.lasso
|
||||
Program: script_name.lasso
|
||||
41
Task/Program-name/Liberty-BASIC/program-name-1.basic
Normal file
41
Task/Program-name/Liberty-BASIC/program-name-1.basic
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
nSize = _MAX_PATH + 2
|
||||
lpFilename$ = space$(nSize); chr$(0)
|
||||
|
||||
calldll #kernel32, "GetModuleFileNameA", _
|
||||
hModule as ulong, _
|
||||
lpFilename$ as ptr, _
|
||||
nSize as ulong, _
|
||||
result as ulong
|
||||
lpFilename$ = left$(lpFilename$,result)
|
||||
|
||||
print "Path to LB exe"
|
||||
print lpFilename$
|
||||
print "current program file (:last one on LRU list)"
|
||||
print getLastLRU$(lbPath$)
|
||||
end
|
||||
|
||||
Function getLastLRU$(lbPath$)
|
||||
open lbPath$+"lbasic404.ini" for input as #1
|
||||
while not(eof(#1))
|
||||
line input #1, a$
|
||||
if instr(a$, "recent files")<>0 then [readRecentFiles]
|
||||
wend
|
||||
getLastLRU$ = "* Failed: Recent files section not found *"
|
||||
close #1
|
||||
exit function
|
||||
|
||||
[readRecentFiles]
|
||||
nRecent = val(word$(a$,1))
|
||||
'print "nRecentFiles", nRecent
|
||||
for i = 1 to nRecent
|
||||
if eof(#1) then
|
||||
getLastLRU$ = "* Failed: File ended while in recent files section *"
|
||||
close #1
|
||||
exit function
|
||||
end if
|
||||
line input #1, a$
|
||||
'print i, a$
|
||||
next
|
||||
close #1
|
||||
getLastLRU$ = a$
|
||||
end function
|
||||
4
Task/Program-name/Liberty-BASIC/program-name-2.basic
Normal file
4
Task/Program-name/Liberty-BASIC/program-name-2.basic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Path to LB exe
|
||||
C:\progs\Liberty BASIC v4.04\liberty.exe
|
||||
current program file (:last one on LRU list)
|
||||
C:\progs\Liberty BASIC v4.04\untitled.bas
|
||||
4
Task/Program-name/Lingo/program-name.lingo
Normal file
4
Task/Program-name/Lingo/program-name.lingo
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
put _player.applicationName
|
||||
-- "lsw.exe"
|
||||
put _movie.name
|
||||
-- "lsw_win_d11.dir"
|
||||
12
Task/Program-name/Lua/program-name.lua
Normal file
12
Task/Program-name/Lua/program-name.lua
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env lua
|
||||
|
||||
function main(arg)
|
||||
local program = arg[0]
|
||||
print("Program: " .. program)
|
||||
end
|
||||
|
||||
if type(package.loaded[(...)]) ~= "userdata" then
|
||||
main(arg)
|
||||
else
|
||||
module(..., package.seeall)
|
||||
end
|
||||
17
Task/Program-name/M2000-Interpreter/program-name.m2000
Normal file
17
Task/Program-name/M2000-Interpreter/program-name.m2000
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
Module Checkit {
|
||||
Declare GetModuleFileName Lib "kernel32.GetModuleFileNameW" {Long hModule, &lpFileName$, Long nSize}
|
||||
a$=string$(chr$(0), 260)
|
||||
namelen=GetModuleFileName(0, &a$, 260)
|
||||
a$=left$(a$, namelen)
|
||||
\\ normally m2000.exe is the caller of m2000.dll, the activeX script language
|
||||
Print Mid$(a$, Rinstr(a$, "\")+1)="m2000.exe"
|
||||
}
|
||||
Checkit
|
||||
\\ command$ return the file's path plus name of script
|
||||
\\ we can use edit "callme.gsb" to paste these, and use USE callme to call it from M2000 console.
|
||||
Module SayIt {
|
||||
Show
|
||||
Print command$
|
||||
a$=key$
|
||||
}
|
||||
SayIt
|
||||
4
Task/Program-name/Make/program-name.make
Normal file
4
Task/Program-name/Make/program-name.make
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
NAME=$(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||
|
||||
all:
|
||||
@echo $(NAME)
|
||||
9
Task/Program-name/Mathematica/program-name.math
Normal file
9
Task/Program-name/Mathematica/program-name.math
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env MathKernel -script
|
||||
ScriptName[] = Piecewise[
|
||||
{
|
||||
{"Interpreted", Position[$CommandLine, "-script", 1] == {}}
|
||||
},
|
||||
$CommandLine[[Position[$CommandLine, "-script", 1][[1,1]] + 1]]
|
||||
]
|
||||
Program = ScriptName[];
|
||||
Print["Program: " <> Program]
|
||||
16
Task/Program-name/Mercury/program-name.mercury
Normal file
16
Task/Program-name/Mercury/program-name.mercury
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
:- module program_name.
|
||||
:- interface.
|
||||
|
||||
:- import_module io.
|
||||
:- pred main(io::di, io::uo) is det.
|
||||
|
||||
:- implementation.
|
||||
|
||||
main(!IO) :-
|
||||
% The first argument is used as the program name if it is not otherwise
|
||||
% available. (We could also have used the predicate io.progname_base/4
|
||||
% if we did not want path preceding the program name.)
|
||||
io.progname("", ProgName, !IO),
|
||||
io.print_line(ProgName, !IO).
|
||||
|
||||
:- end_module program_name.
|
||||
1
Task/Program-name/Nanoquery/program-name.nanoquery
Normal file
1
Task/Program-name/Nanoquery/program-name.nanoquery
Normal file
|
|
@ -0,0 +1 @@
|
|||
println args[1]
|
||||
4
Task/Program-name/Nemerle/program-name.nemerle
Normal file
4
Task/Program-name/Nemerle/program-name.nemerle
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
using System.Environment;
|
||||
...
|
||||
def program_name = GetCommandLineArgs()[0];
|
||||
...
|
||||
8
Task/Program-name/NetRexx/program-name.netrexx
Normal file
8
Task/Program-name/NetRexx/program-name.netrexx
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
package org.rosettacode.samples
|
||||
|
||||
say 'Source: ' source
|
||||
say 'Program:' System.getProperty('sun.java.command')
|
||||
return
|
||||
5
Task/Program-name/NewLISP/program-name.l
Normal file
5
Task/Program-name/NewLISP/program-name.l
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env newlisp
|
||||
|
||||
(let ((program (main-args 1)))
|
||||
(println (format "Program: %s" program))
|
||||
(exit))
|
||||
3
Task/Program-name/Nim/program-name.nim
Normal file
3
Task/Program-name/Nim/program-name.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import os
|
||||
echo getAppFilename() # Prints the full path of the executed file
|
||||
echo paramStr(0) # Prints argv[0]
|
||||
3
Task/Program-name/OCaml/program-name.ocaml
Normal file
3
Task/Program-name/OCaml/program-name.ocaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
let () =
|
||||
print_endline Sys.executable_name;
|
||||
print_endline Sys.argv.(0)
|
||||
7
Task/Program-name/Oberon-2/program-name.oberon
Normal file
7
Task/Program-name/Oberon-2/program-name.oberon
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
MODULE ProgramName;
|
||||
IMPORT
|
||||
NPCT:Args,
|
||||
Out;
|
||||
BEGIN
|
||||
Out.Object("Program name: " + Args.Get(0));Out.Ln
|
||||
END ProgramName.
|
||||
16
Task/Program-name/Objective-C/program-name-1.m
Normal file
16
Task/Program-name/Objective-C/program-name-1.m
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
@autoreleasepool {
|
||||
|
||||
char *program = argv[0];
|
||||
printf("Program: %s\n", program);
|
||||
|
||||
// Alternatively:
|
||||
NSString *program2 = [[NSProcessInfo processInfo] processName];
|
||||
NSLog(@"Program: %@\n", program2);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
Task/Program-name/Objective-C/program-name-2.m
Normal file
3
Task/Program-name/Objective-C/program-name-2.m
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
$ gcc -o scriptname -framework foundation scriptname.m
|
||||
$ ./scriptname
|
||||
Program: ./scriptname
|
||||
6
Task/Program-name/Octave/program-name.octave
Normal file
6
Task/Program-name/Octave/program-name.octave
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
function main()
|
||||
program = program_name();
|
||||
printf("Program: %s", program);
|
||||
endfunction
|
||||
|
||||
main();
|
||||
1
Task/Program-name/Ol/program-name.ol
Normal file
1
Task/Program-name/Ol/program-name.ol
Normal file
|
|
@ -0,0 +1 @@
|
|||
(print (car *vm-args*))
|
||||
1
Task/Program-name/Order/program-name.order
Normal file
1
Task/Program-name/Order/program-name.order
Normal file
|
|
@ -0,0 +1 @@
|
|||
__FILE__
|
||||
4
Task/Program-name/PHP/program-name.php
Normal file
4
Task/Program-name/PHP/program-name.php
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
$program = $_SERVER["SCRIPT_NAME"];
|
||||
echo "Program: $program\n";
|
||||
?>
|
||||
8
Task/Program-name/Pascal/program-name.pas
Normal file
8
Task/Program-name/Pascal/program-name.pas
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
program ScriptName;
|
||||
var
|
||||
prog : String;
|
||||
begin
|
||||
prog := ParamStr(0);
|
||||
write('Program: ');
|
||||
writeln(prog)
|
||||
end.
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue