exists.out 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. 1
  2. 0
  3. NAME
  4. exists - check whether items exist
  5. SYNOPSIS
  6. exists [EXPRESSION]
  7. DESCRIPTION
  8. Checks whether the given item exists and returns an exit status of 0 if it does, else 1.
  9. OPTIONS
  10. -a ARRAY
  11. array var is not empty
  12. -b BINARY
  13. binary is in PATH
  14. -d PATH
  15. path is a directory
  16. This is the same as test -d
  17. -f PATH
  18. path is a file
  19. This is the same as test -f
  20. --fn FUNCTION
  21. function is defined
  22. -s STRING
  23. string var is not empty
  24. STRING
  25. string is not empty
  26. This is the same as test -n
  27. EXAMPLES
  28. Test if the file exists:
  29. exists -f FILE && echo 'The FILE exists' || echo 'The FILE does not exist'
  30. Test if some-command exists in the path and is executable:
  31. exists -b some-command && echo 'some-command exists' || echo 'some-command does not exist'
  32. Test if variable exists AND is not empty
  33. exists -s myVar && echo "myVar exists: $myVar" || echo 'myVar does not exist or is empty'
  34. NOTE: Don't use the '$' sigil, but only the name of the variable to check
  35. Test if array exists and is not empty
  36. exists -a myArr && echo "myArr exists: @myArr" || echo 'myArr does not exist or is empty'
  37. NOTE: Don't use the '@' sigil, but only the name of the array to check
  38. Test if a function named 'myFunc' exists
  39. exists --fn myFunc && myFunc || echo 'No function with name myFunc found'
  40. AUTHOR
  41. Written by Fabian Würfl.
  42. Heavily based on implementation of the test builtin, which was written by Michael Murphy.
  43. BUGS
  44. Please report all bugs at https://gitlab.redox-os.org/redox-os/ion/issues.
  45. Ion is still in active development and help in finding bugs is much appreciated!
  46. AUTHORS
  47. The Ion developers, under the Redox OS organisation
  48. 0
  49. NAME
  50. exists - check whether items exist
  51. SYNOPSIS
  52. exists [EXPRESSION]
  53. DESCRIPTION
  54. Checks whether the given item exists and returns an exit status of 0 if it does, else 1.
  55. OPTIONS
  56. -a ARRAY
  57. array var is not empty
  58. -b BINARY
  59. binary is in PATH
  60. -d PATH
  61. path is a directory
  62. This is the same as test -d
  63. -f PATH
  64. path is a file
  65. This is the same as test -f
  66. --fn FUNCTION
  67. function is defined
  68. -s STRING
  69. string var is not empty
  70. STRING
  71. string is not empty
  72. This is the same as test -n
  73. EXAMPLES
  74. Test if the file exists:
  75. exists -f FILE && echo 'The FILE exists' || echo 'The FILE does not exist'
  76. Test if some-command exists in the path and is executable:
  77. exists -b some-command && echo 'some-command exists' || echo 'some-command does not exist'
  78. Test if variable exists AND is not empty
  79. exists -s myVar && echo "myVar exists: $myVar" || echo 'myVar does not exist or is empty'
  80. NOTE: Don't use the '$' sigil, but only the name of the variable to check
  81. Test if array exists and is not empty
  82. exists -a myArr && echo "myArr exists: @myArr" || echo 'myArr does not exist or is empty'
  83. NOTE: Don't use the '@' sigil, but only the name of the array to check
  84. Test if a function named 'myFunc' exists
  85. exists --fn myFunc && myFunc || echo 'No function with name myFunc found'
  86. AUTHOR
  87. Written by Fabian Würfl.
  88. Heavily based on implementation of the test builtin, which was written by Michael Murphy.
  89. BUGS
  90. Please report all bugs at https://gitlab.redox-os.org/redox-os/ion/issues.
  91. Ion is still in active development and help in finding bugs is much appreciated!
  92. AUTHORS
  93. The Ion developers, under the Redox OS organisation
  94. 0
  95. 1
  96. 0
  97. 0
  98. 0
  99. 0
  100. 1
  101. element
  102. 0
  103. 0
  104. 0
  105. PATH = testing/
  106. empty_file
  107. executable_file
  108. file_with_text
  109. symlink
  110. 0
  111. 1
  112. 1
  113. Reset PATH to old path
  114. 0
  115. 0
  116. 1
  117. 1
  118. 0
  119. 1
  120. 0
  121. 1
  122. 0
  123. 0
  124. emptyvar =
  125. 1
  126. testvar = foobar
  127. 0
  128. 0
  129. 0
  130. ion: expansion error: Variable does not exist