Skip to main content
-1 byte using a raw tab
Source Link
EasyasPi
  • 5k
  • 17
  • 22

Knight (C/AST, *nix), 5050 49 bytes

\t represents a raw tab.

O`"catO`"cat `tr '\0' '\t'<'\t'</proc/$PPID/cmdline|cut -f3`"
f3`"

Doesn't work in the golfed interpreter for some reason, so no TIO.

Abuses the shell command built-in <backtick> and the standardized command line args for Knight, which is knight -f file.kn

/proc/$PPID/cmdline obtains the \0-separated command line arguments of the parent process (which is the knight interpreter itself), tr '\0' '\t' replaces \0 with \t, and cut -f3 takes the third tab-delimited argument. Then, we just cat the file and output the result.

A similar result can be done using the -e flag, but that doesn't read the source file from the disk (unless you count the cmdline file)

-1 byte using a raw tab over \t

Knight (C/AST, *nix), 50 bytes

O`"cat `tr '\0' '\t'</proc/$PPID/cmdline|cut -f3`"

Doesn't work in the golfed interpreter for some reason, so no TIO.

Abuses the shell command built-in <backtick> and the standardized command line args for Knight, which is knight -f file.kn

/proc/$PPID/cmdline obtains the \0-separated command line arguments of the parent process (which is the knight interpreter itself), tr '\0' '\t' replaces \0 with \t, and cut -f3 takes the third tab-delimited argument. Then, we just cat the file and output the result.

A similar result can be done using the -e flag, but that doesn't read the source file from the disk (unless you count the cmdline file)

Knight (C/AST, *nix), 50 49 bytes

\t represents a raw tab.

O`"cat `tr '\0' '\t'</proc/$PPID/cmdline|cut -f3`"

Doesn't work in the golfed interpreter for some reason, so no TIO.

Abuses the shell command built-in <backtick> and the standardized command line args for Knight, which is knight -f file.kn

/proc/$PPID/cmdline obtains the \0-separated command line arguments of the parent process (which is the knight interpreter itself), tr '\0' '\t' replaces \0 with \t, and cut -f3 takes the third tab-delimited argument. Then, we just cat the file and output the result.

A similar result can be done using the -e flag, but that doesn't read the source file from the disk (unless you count the cmdline file)

-1 byte using a raw tab over \t

Source Link
EasyasPi
  • 5k
  • 17
  • 22

Knight (C/AST, *nix), 50 bytes

O`"cat `tr '\0' '\t'</proc/$PPID/cmdline|cut -f3`"

Doesn't work in the golfed interpreter for some reason, so no TIO.

Abuses the shell command built-in <backtick> and the standardized command line args for Knight, which is knight -f file.kn

/proc/$PPID/cmdline obtains the \0-separated command line arguments of the parent process (which is the knight interpreter itself), tr '\0' '\t' replaces \0 with \t, and cut -f3 takes the third tab-delimited argument. Then, we just cat the file and output the result.

A similar result can be done using the -e flag, but that doesn't read the source file from the disk (unless you count the cmdline file)