1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <u.h> #include <libc.h> void main(void) { char buf[512], *p; p = "???"; if(getwd(buf, sizeof buf)){ p = strrchr(buf, '/'); if(p == nil) p = buf; else if(p>buf || p[1]!='\0') p++; } write(1, p, strlen(p)); exits(0); }