Advertisement
FranzVuttke

alias_what2up

Jul 19th, 2024 (edited)
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.86 KB | Source Code | 0 0
  1. #!/bin/bash
  2.  
  3. # see: How to disable "WARNING: apt does not have a stable CLI interface..." [closed]
  4. # https://serverfault.com/questions/958003/how-to-disable-warning-apt-does-not-have-a-stable-cli-interface
  5.  
  6. echo `sudo apt update 2>/dev/null | grep "packages" | cut -d " " -f1`
  7.  
  8. # !!! TIP:  
  9.  
  10. # '2>/dev/null/'
  11.  
  12. #- "In the *nix world, output to the command line is generally of two flavors, stdout (standard # # output) and stderr      # (standard error). Well-behaved programs send their normal output to stdout and any warnings or error # # messages to #stderr. So, if you want errors/warnings to disappear, you can usually accomplish this by throwing away any    # messages on #stderr using the output redirection 2>/dev/null. (In English, that's "redirect (>) the second output channel  
  13. # (2, which is stderr) to /dev/null (which just throws away everything sent there)"."
  14.  
  15. #!/bin/bash
  16.  
  17. #\n
  18. # created by OuNiS 07.2024\n
  19. #\n\n\n
  20.  
  21. # from alias to bash file
  22. # alias what2up='`sudo apt update 2>/dev/null | grep "packages" | cut -d " " -f1 | tail -1`'
  23. #
  24.  
  25. # *** WARNING ***
  26. # IN CASE OF:
  27. # "...apt could change tomorrow to calling them "distributions" instead of "packages"
  28. # (because it "does not have a stable CLI interface yet")
  29. # and this would completely break your pipeline."
  30. #
  31. # quoted from:
  32. # https://serverfault.com/questions/958003/how-to-disable-warning-apt-does-not-have-a-stable-cli-interface
  33. if [ -z "$1" ]; then
  34.     PACKAGES="package"
  35. else
  36.     PACKAGES=$1
  37. fi
  38. # *** WARNING ***
  39.        
  40. # echo $PACKAGES
  41.  
  42. echo "Please wait..."
  43. PKGNUM=`sudo apt update 2>/dev/null | grep "$PACKAGES" | cut -d " " -f1 | tail -1`
  44.  
  45. # echo $PKGNUM
  46.    
  47. if  [ -z "$PKGNUM" ] || [ "$PKGNUM" = "All" ] || [ "$PKGNUM" = "Wszystkie" ]; then
  48.     echo "The system is fully updated!!!"
  49. else
  50.     echo -e "Packages to be updated:$CL_YELLOW$CL_BOLD $PKGNUM $CL_DEF"
  51. fi
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement