I'm using FISH (Friendly Interactive SHell)
and I created 2 functions :
function send
command cat $argv | nc -l 55555
end
--> send a file via nc
function senddir
command tar cjf copy.tar $argv; cat copy.tar | nc -l 55555; rm copy.tar
end
--> send a dir by compressing it via nc
Now, I wan't to refactor and create a send function that does both, for this I need to check if argv is a dir. How can I do it with fish?
Same as in other shells, although in
fish
you are actually using an external program, not a shell built-in.Actually, you don't need the temp file and can pipe the output of
tar
directly tonc -l
, which allows you to simplify the function to