1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:07:45 +00:00

Shell: add type builtin

This commit is contained in:
jacob gw 2021-04-10 23:25:49 -04:00 committed by Andreas Kling
parent 1d7a0ab5ea
commit cb22a6642d
3 changed files with 96 additions and 0 deletions

View file

@ -0,0 +1,24 @@
#!/bin/sh
source $(dirname "$0")/test-commons.inc
if not [ "$(type ls)" = "ls is $(which ls)" ] { fail "'type' on a binary not working" }
if not [ "$(type pwd)" = "pwd is a shell builtin" ] { fail "'type' on a builtin not working" }
f() { ls }
if not [ "$(type f)" = "f is a function f() { ls }" ] { fail "'type' on a function not working" }
if not [ "$(type f -f)" = "f is a function" ] { fail "'type' on a function not working with -f" }
alias l=ls
if not [ "$(type l)" = "l is aliased to `ls`" ] { fail "'type' on a alias not working" }
if not [ "$(type l ls)" = "l is aliased to `ls` ls is $(which ls)" ] { fail "'type' on multiple commands not working" }
echo PASS