logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git

link.c (503B)


  1. // Collection of Unix tools, comparable to coreutils
  2. // SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. // SPDX-License-Identifier: MPL-2.0
  4. #define _POSIX_C_SOURCE 200809L
  5. #include <stdio.h> /* perror, fprintf */
  6. #include <unistd.h> /* link */
  7. int
  8. main(int argc, char *argv[])
  9. {
  10. if(argc != 3)
  11. {
  12. fprintf(stderr, "usage: link <reference> <destination>\n");
  13. return 1;
  14. }
  15. if(link(argv[1], argv[2]) != 0)
  16. {
  17. perror("link");
  18. return 1;
  19. }
  20. return 0;
  21. }