dog

list directory when argument is a directory, cat file when the argument is a file
git clone https://noulin.net/git/dog.git
Log | Files | Refs | LICENSE

dog.c (486B)


      1 #! /usr/bin/env sheepy
      2 
      3 #include "libsheepyObject.h"
      4 
      5 int argc; char **argv;
      6 
      7 #define LS "ls -al --color"
      8 #define CAT "cat "
      9 
     10 int main(int ARGC, char** ARGV) {
     11 
     12   argc = ARGC; argv = ARGV;
     13 
     14   initLibsheepy(argv[0]);
     15 
     16   if (argc < 2) {
     17     system(LS);
     18   }
     19 
     20   forEachCharP(&argv[1], arg) {
     21     if (isDir(*arg)) {
     22       char *s = appendS(LS " ", *arg);
     23       systemNFreeG(s);
     24     }
     25     else {
     26       char *s = appendS(CAT, *arg);
     27       systemNFreeG(s);
     28     }
     29   }
     30 
     31   finalizeLibsheepy();
     32 
     33 }