sudo/doas does not give the expected permissions when using an eshell alias: When no alias has been defined: ~ $ which cp eshell/cp is a native-compiled Lisp function in ‘em-unix.el’. ~ $ touch test ~ $ cp test /boot/efi/ Opening output file: Permission denied, /boot/efi/test ~ $ sudo cp test /boot/efi/ ~ $ echo $? 0 But after defining the alias: ~ $ alias cp '*cp $*' ~ $ which cp cp is an alias, defined as "*cp $*" ~ $ sudo cp test /boot/efi/ /usr/bin/cp: cannot stat '/boot/efi/test': Permission denied I have attached a patch with a possible fix.