Shell.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. /*
  2. * Copyright (c) 2020-2022, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include "Job.h"
  8. #include "Parser.h"
  9. #include <AK/Array.h>
  10. #include <AK/CircularQueue.h>
  11. #include <AK/DeprecatedString.h>
  12. #include <AK/HashMap.h>
  13. #include <AK/StackInfo.h>
  14. #include <AK/StringBuilder.h>
  15. #include <AK/StringView.h>
  16. #include <AK/Types.h>
  17. #include <AK/Vector.h>
  18. #include <LibCore/Notifier.h>
  19. #include <LibCore/Object.h>
  20. #include <LibLine/Editor.h>
  21. #include <LibMain/Main.h>
  22. #include <termios.h>
  23. #define ENUMERATE_SHELL_BUILTINS() \
  24. __ENUMERATE_SHELL_BUILTIN(alias) \
  25. __ENUMERATE_SHELL_BUILTIN(where) \
  26. __ENUMERATE_SHELL_BUILTIN(cd) \
  27. __ENUMERATE_SHELL_BUILTIN(cdh) \
  28. __ENUMERATE_SHELL_BUILTIN(pwd) \
  29. __ENUMERATE_SHELL_BUILTIN(type) \
  30. __ENUMERATE_SHELL_BUILTIN(exec) \
  31. __ENUMERATE_SHELL_BUILTIN(exit) \
  32. __ENUMERATE_SHELL_BUILTIN(export) \
  33. __ENUMERATE_SHELL_BUILTIN(glob) \
  34. __ENUMERATE_SHELL_BUILTIN(unalias) \
  35. __ENUMERATE_SHELL_BUILTIN(unset) \
  36. __ENUMERATE_SHELL_BUILTIN(history) \
  37. __ENUMERATE_SHELL_BUILTIN(umask) \
  38. __ENUMERATE_SHELL_BUILTIN(not ) \
  39. __ENUMERATE_SHELL_BUILTIN(dirs) \
  40. __ENUMERATE_SHELL_BUILTIN(pushd) \
  41. __ENUMERATE_SHELL_BUILTIN(popd) \
  42. __ENUMERATE_SHELL_BUILTIN(setopt) \
  43. __ENUMERATE_SHELL_BUILTIN(shift) \
  44. __ENUMERATE_SHELL_BUILTIN(source) \
  45. __ENUMERATE_SHELL_BUILTIN(time) \
  46. __ENUMERATE_SHELL_BUILTIN(jobs) \
  47. __ENUMERATE_SHELL_BUILTIN(disown) \
  48. __ENUMERATE_SHELL_BUILTIN(fg) \
  49. __ENUMERATE_SHELL_BUILTIN(bg) \
  50. __ENUMERATE_SHELL_BUILTIN(wait) \
  51. __ENUMERATE_SHELL_BUILTIN(dump) \
  52. __ENUMERATE_SHELL_BUILTIN(kill) \
  53. __ENUMERATE_SHELL_BUILTIN(noop) \
  54. __ENUMERATE_SHELL_BUILTIN(break) \
  55. __ENUMERATE_SHELL_BUILTIN(continue) \
  56. __ENUMERATE_SHELL_BUILTIN(read) \
  57. __ENUMERATE_SHELL_BUILTIN(run_with_env) \
  58. __ENUMERATE_SHELL_BUILTIN(argsparser_parse)
  59. #define ENUMERATE_SHELL_OPTIONS() \
  60. __ENUMERATE_SHELL_OPTION(inline_exec_keep_empty_segments, false, "Keep empty segments in inline execute $(...)") \
  61. __ENUMERATE_SHELL_OPTION(verbose, false, "Announce every command that is about to be executed") \
  62. __ENUMERATE_SHELL_OPTION(invoke_program_for_autocomplete, false, "Attempt to use the program being completed itself for autocompletion via --complete")
  63. #define ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS() \
  64. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(concat_lists) \
  65. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(length) \
  66. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(length_across) \
  67. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(remove_suffix) \
  68. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(remove_prefix) \
  69. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(regex_replace) \
  70. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(filter_glob) \
  71. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(split) \
  72. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(join) \
  73. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(value_or_default) \
  74. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(assign_default) \
  75. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(error_if_empty) \
  76. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(null_or_alternative) \
  77. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(defined_value_or_default) \
  78. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(assign_defined_default) \
  79. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(error_if_unset) \
  80. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(null_if_unset_or_alternative) \
  81. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(length_of_variable) \
  82. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(reexpand) \
  83. __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(math)
  84. namespace Shell {
  85. class Shell;
  86. class Shell : public Core::Object {
  87. C_OBJECT(Shell);
  88. public:
  89. constexpr static auto local_init_file_path = "~/.shellrc";
  90. constexpr static auto global_init_file_path = "/etc/shellrc";
  91. constexpr static auto local_posix_init_file_path = "~/.posixshrc";
  92. constexpr static auto global_posix_init_file_path = "/etc/posixshrc";
  93. bool should_format_live() const { return m_should_format_live; }
  94. void set_live_formatting(bool value) { m_should_format_live = value; }
  95. void setup_signals();
  96. struct SourcePosition {
  97. DeprecatedString source_file;
  98. DeprecatedString literal_source_text;
  99. Optional<AST::Position> position;
  100. };
  101. struct RunnablePath {
  102. enum class Kind {
  103. Builtin,
  104. Function,
  105. Alias,
  106. Executable,
  107. };
  108. Kind kind;
  109. DeprecatedString path;
  110. bool operator<(RunnablePath const& other) const
  111. {
  112. return path < other.path;
  113. }
  114. bool operator==(RunnablePath const&) const = default;
  115. };
  116. struct RunnablePathComparator {
  117. int operator()(RunnablePath const& lhs, RunnablePath const& rhs)
  118. {
  119. if (lhs.path > rhs.path)
  120. return 1;
  121. if (lhs.path < rhs.path)
  122. return -1;
  123. return 0;
  124. }
  125. int operator()(StringView lhs, RunnablePath const& rhs)
  126. {
  127. if (lhs > rhs.path)
  128. return 1;
  129. if (lhs < rhs.path)
  130. return -1;
  131. return 0;
  132. }
  133. };
  134. int run_command(StringView, Optional<SourcePosition> = {});
  135. Optional<RunnablePath> runnable_path_for(StringView);
  136. Optional<DeprecatedString> help_path_for(Vector<RunnablePath> visited, RunnablePath const& runnable_path);
  137. ErrorOr<RefPtr<Job>> run_command(const AST::Command&);
  138. Vector<NonnullRefPtr<Job>> run_commands(Vector<AST::Command>&);
  139. bool run_file(DeprecatedString const&, bool explicitly_invoked = true);
  140. ErrorOr<bool> run_builtin(const AST::Command&, Vector<NonnullRefPtr<AST::Rewiring>> const&, int& retval);
  141. bool has_builtin(StringView) const;
  142. ErrorOr<RefPtr<AST::Node>> run_immediate_function(StringView name, AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const&);
  143. static bool has_immediate_function(StringView);
  144. void block_on_job(RefPtr<Job>);
  145. void block_on_pipeline(RefPtr<AST::Pipeline>);
  146. DeprecatedString prompt() const;
  147. static DeprecatedString expand_tilde(StringView expression);
  148. static Vector<DeprecatedString> expand_globs(StringView path, StringView base);
  149. static Vector<DeprecatedString> expand_globs(Vector<StringView> path_segments, StringView base);
  150. ErrorOr<Vector<AST::Command>> expand_aliases(Vector<AST::Command>);
  151. DeprecatedString resolve_path(DeprecatedString) const;
  152. DeprecatedString resolve_alias(StringView) const;
  153. static bool has_history_event(StringView);
  154. ErrorOr<RefPtr<AST::Value const>> get_argument(size_t) const;
  155. ErrorOr<RefPtr<AST::Value const>> lookup_local_variable(StringView) const;
  156. ErrorOr<DeprecatedString> local_variable_or(StringView, DeprecatedString const&) const;
  157. void set_local_variable(DeprecatedString const&, RefPtr<AST::Value>, bool only_in_current_frame = false);
  158. void unset_local_variable(StringView, bool only_in_current_frame = false);
  159. void define_function(DeprecatedString name, Vector<DeprecatedString> argnames, RefPtr<AST::Node> body);
  160. bool has_function(StringView);
  161. bool invoke_function(const AST::Command&, int& retval);
  162. DeprecatedString format(StringView, ssize_t& cursor) const;
  163. RefPtr<Line::Editor> editor() const { return m_editor; }
  164. struct LocalFrame {
  165. LocalFrame(DeprecatedString name, HashMap<DeprecatedString, RefPtr<AST::Value>> variables)
  166. : name(move(name))
  167. , local_variables(move(variables))
  168. {
  169. }
  170. DeprecatedString name;
  171. HashMap<DeprecatedString, RefPtr<AST::Value>> local_variables;
  172. };
  173. struct Frame {
  174. Frame(Vector<NonnullOwnPtr<LocalFrame>>& frames, LocalFrame const& frame)
  175. : frames(frames)
  176. , frame(frame)
  177. {
  178. }
  179. ~Frame();
  180. void leak_frame() { should_destroy_frame = false; }
  181. private:
  182. Vector<NonnullOwnPtr<LocalFrame>>& frames;
  183. LocalFrame const& frame;
  184. bool should_destroy_frame { true };
  185. };
  186. [[nodiscard]] Frame push_frame(DeprecatedString name);
  187. void pop_frame();
  188. struct Promise {
  189. struct Data {
  190. struct Unveil {
  191. DeprecatedString path;
  192. DeprecatedString access;
  193. };
  194. DeprecatedString exec_promises;
  195. Vector<Unveil> unveils;
  196. } data;
  197. IntrusiveListNode<Promise> node;
  198. using List = IntrusiveList<&Promise::node>;
  199. };
  200. struct ScopedPromise {
  201. ScopedPromise(Promise::List& promises, Promise&& promise)
  202. : promises(promises)
  203. , promise(move(promise))
  204. {
  205. promises.append(this->promise);
  206. }
  207. ~ScopedPromise()
  208. {
  209. promises.remove(promise);
  210. }
  211. Promise::List& promises;
  212. Promise promise;
  213. };
  214. [[nodiscard]] ScopedPromise promise(Promise::Data data)
  215. {
  216. return { m_active_promises, { move(data), {} } };
  217. }
  218. enum class EscapeMode {
  219. Bareword,
  220. SingleQuotedString,
  221. DoubleQuotedString,
  222. };
  223. static DeprecatedString escape_token_for_double_quotes(StringView token);
  224. static DeprecatedString escape_token_for_single_quotes(StringView token);
  225. static DeprecatedString escape_token(StringView token, EscapeMode = EscapeMode::Bareword);
  226. static DeprecatedString escape_token(Utf32View token, EscapeMode = EscapeMode::Bareword);
  227. static DeprecatedString unescape_token(StringView token);
  228. enum class SpecialCharacterEscapeMode {
  229. Untouched,
  230. Escaped,
  231. QuotedAsEscape,
  232. QuotedAsHex,
  233. };
  234. static SpecialCharacterEscapeMode special_character_escape_mode(u32 c, EscapeMode);
  235. static bool is_glob(StringView);
  236. static Vector<StringView> split_path(StringView);
  237. enum class ExecutableOnly {
  238. Yes,
  239. No
  240. };
  241. ErrorOr<void> highlight(Line::Editor&) const;
  242. Vector<Line::CompletionSuggestion> complete();
  243. Vector<Line::CompletionSuggestion> complete(StringView);
  244. Vector<Line::CompletionSuggestion> complete_program_name(StringView, size_t offset, EscapeMode = EscapeMode::Bareword);
  245. Vector<Line::CompletionSuggestion> complete_variable(StringView, size_t offset);
  246. Vector<Line::CompletionSuggestion> complete_user(StringView, size_t offset);
  247. Vector<Line::CompletionSuggestion> complete_immediate_function_name(StringView, size_t offset);
  248. Vector<Line::CompletionSuggestion> complete_path(StringView base, StringView, size_t offset, ExecutableOnly executable_only, AST::Node const* command_node, AST::Node const*, EscapeMode = EscapeMode::Bareword);
  249. Vector<Line::CompletionSuggestion> complete_option(StringView, StringView, size_t offset, AST::Node const* command_node, AST::Node const*);
  250. ErrorOr<Vector<Line::CompletionSuggestion>> complete_via_program_itself(size_t offset, AST::Node const* command_node, AST::Node const*, EscapeMode escape_mode, StringView known_program_name);
  251. void restore_ios();
  252. u64 find_last_job_id() const;
  253. Job* find_job(u64 id, bool is_pid = false);
  254. Job* current_job() const { return m_current_job; }
  255. void kill_job(Job const*, int sig);
  256. DeprecatedString get_history_path();
  257. void print_path(StringView path);
  258. void cache_path();
  259. bool read_single_line();
  260. void notify_child_event();
  261. bool posix_mode() const { return m_in_posix_mode; }
  262. struct termios termios;
  263. struct termios default_termios;
  264. bool was_interrupted { false };
  265. bool was_resized { false };
  266. DeprecatedString cwd;
  267. DeprecatedString username;
  268. DeprecatedString home;
  269. constexpr static auto TTYNameSize = 32;
  270. constexpr static auto HostNameSize = 64;
  271. char ttyname[TTYNameSize];
  272. char hostname[HostNameSize];
  273. uid_t uid;
  274. Optional<int> last_return_code;
  275. Vector<DeprecatedString> directory_stack;
  276. CircularQueue<DeprecatedString, 8> cd_history; // FIXME: have a configurable cd history length
  277. HashMap<u64, NonnullRefPtr<Job>> jobs;
  278. Vector<RunnablePath, 256> cached_path;
  279. DeprecatedString current_script;
  280. enum ShellEventType {
  281. ReadLine,
  282. };
  283. enum class ShellError {
  284. None,
  285. InternalControlFlowBreak,
  286. InternalControlFlowContinue,
  287. InternalControlFlowInterrupted,
  288. InternalControlFlowKilled,
  289. EvaluatedSyntaxError,
  290. NonExhaustiveMatchRules,
  291. InvalidGlobError,
  292. InvalidSliceContentsError,
  293. OpenFailure,
  294. OutOfMemory,
  295. LaunchError,
  296. PipeFailure,
  297. WriteFailure,
  298. };
  299. void raise_error(ShellError kind, DeprecatedString description, Optional<AST::Position> position = {})
  300. {
  301. m_error = kind;
  302. m_error_description = move(description);
  303. if (m_source_position.has_value() && position.has_value())
  304. m_source_position.value().position = position.release_value();
  305. }
  306. bool has_error(ShellError err) const { return m_error == err; }
  307. bool has_any_error() const { return !has_error(ShellError::None); }
  308. DeprecatedString const& error_description() const { return m_error_description; }
  309. ShellError take_error()
  310. {
  311. auto err = m_error;
  312. m_error = ShellError::None;
  313. m_error_description = {};
  314. return err;
  315. }
  316. void possibly_print_error() const;
  317. static bool is_control_flow(ShellError error)
  318. {
  319. switch (error) {
  320. case ShellError::InternalControlFlowBreak:
  321. case ShellError::InternalControlFlowContinue:
  322. case ShellError::InternalControlFlowInterrupted:
  323. case ShellError::InternalControlFlowKilled:
  324. return true;
  325. default:
  326. return false;
  327. }
  328. }
  329. #define __ENUMERATE_SHELL_OPTION(name, default_, description) \
  330. bool name { default_ };
  331. struct Options {
  332. ENUMERATE_SHELL_OPTIONS();
  333. } options;
  334. #undef __ENUMERATE_SHELL_OPTION
  335. private:
  336. Shell(Line::Editor&, bool attempt_interactive, bool posix_mode = false);
  337. Shell();
  338. virtual ~Shell() override;
  339. RefPtr<AST::Node> parse(StringView, bool interactive = false, bool as_command = true) const;
  340. void timer_event(Core::TimerEvent&) override;
  341. bool is_allowed_to_modify_termios(const AST::Command&) const;
  342. void bring_cursor_to_beginning_of_a_line() const;
  343. Optional<int> resolve_job_spec(StringView);
  344. void add_entry_to_cache(RunnablePath const&);
  345. void remove_entry_from_cache(StringView);
  346. void stop_all_jobs();
  347. Job* m_current_job { nullptr };
  348. LocalFrame* find_frame_containing_local_variable(StringView name);
  349. LocalFrame const* find_frame_containing_local_variable(StringView name) const
  350. {
  351. return const_cast<Shell*>(this)->find_frame_containing_local_variable(name);
  352. }
  353. void run_tail(RefPtr<Job>);
  354. void run_tail(const AST::Command&, const AST::NodeWithAction&, int head_exit_code);
  355. [[noreturn]] void execute_process(Vector<char const*>&& argv);
  356. ErrorOr<void> execute_process(Span<StringView> argv);
  357. virtual void custom_event(Core::CustomEvent&) override;
  358. #define __ENUMERATE_SHELL_IMMEDIATE_FUNCTION(name) \
  359. ErrorOr<RefPtr<AST::Node>> immediate_##name(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const&);
  360. ENUMERATE_SHELL_IMMEDIATE_FUNCTIONS();
  361. #undef __ENUMERATE_SHELL_IMMEDIATE_FUNCTION
  362. ErrorOr<RefPtr<AST::Node>> immediate_length_impl(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const&, bool across);
  363. #define __ENUMERATE_SHELL_BUILTIN(builtin) \
  364. ErrorOr<int> builtin_##builtin(Main::Arguments);
  365. ENUMERATE_SHELL_BUILTINS();
  366. #undef __ENUMERATE_SHELL_BUILTIN
  367. static constexpr Array builtin_names = {
  368. #define __ENUMERATE_SHELL_BUILTIN(builtin) #builtin##sv,
  369. ENUMERATE_SHELL_BUILTINS()
  370. #undef __ENUMERATE_SHELL_BUILTIN
  371. ":"sv, // POSIX-y name for "noop".
  372. };
  373. bool m_should_ignore_jobs_on_next_exit { false };
  374. pid_t m_pid { 0 };
  375. struct ShellFunction {
  376. DeprecatedString name;
  377. Vector<DeprecatedString> arguments;
  378. RefPtr<AST::Node> body;
  379. };
  380. HashMap<DeprecatedString, ShellFunction> m_functions;
  381. Vector<NonnullOwnPtr<LocalFrame>> m_local_frames;
  382. Promise::List m_active_promises;
  383. Vector<NonnullRefPtr<AST::Redirection>> m_global_redirections;
  384. HashMap<DeprecatedString, DeprecatedString> m_aliases;
  385. bool m_is_interactive { true };
  386. bool m_is_subshell { false };
  387. bool m_should_reinstall_signal_handlers { true };
  388. bool m_in_posix_mode { false };
  389. ShellError m_error { ShellError::None };
  390. DeprecatedString m_error_description;
  391. Optional<SourcePosition> m_source_position;
  392. bool m_should_format_live { false };
  393. RefPtr<Line::Editor> m_editor;
  394. bool m_default_constructed { false };
  395. mutable bool m_last_continuation_state { false }; // false == not needed.
  396. Optional<size_t> m_history_autosave_time;
  397. StackInfo m_completion_stack_info;
  398. };
  399. [[maybe_unused]] static constexpr bool is_word_character(char c)
  400. {
  401. return c == '_' || (c <= 'Z' && c >= 'A') || (c <= 'z' && c >= 'a') || (c <= '9' && c >= '0');
  402. }
  403. inline size_t find_offset_into_node(StringView unescaped_text, size_t escaped_offset, Shell::EscapeMode escape_mode)
  404. {
  405. size_t unescaped_offset = 0;
  406. size_t offset = 0;
  407. auto do_find_offset = [&](auto& unescaped_text) {
  408. for (auto c : unescaped_text) {
  409. if (offset == escaped_offset)
  410. return unescaped_offset;
  411. switch (Shell::special_character_escape_mode(c, escape_mode)) {
  412. case Shell::SpecialCharacterEscapeMode::Untouched:
  413. break;
  414. case Shell::SpecialCharacterEscapeMode::Escaped:
  415. ++offset; // X -> \X
  416. break;
  417. case Shell::SpecialCharacterEscapeMode::QuotedAsEscape:
  418. switch (escape_mode) {
  419. case Shell::EscapeMode::Bareword:
  420. offset += 3; // X -> "\Y"
  421. break;
  422. case Shell::EscapeMode::SingleQuotedString:
  423. offset += 5; // X -> '"\Y"'
  424. break;
  425. case Shell::EscapeMode::DoubleQuotedString:
  426. offset += 1; // X -> \Y
  427. break;
  428. }
  429. break;
  430. case Shell::SpecialCharacterEscapeMode::QuotedAsHex:
  431. switch (escape_mode) {
  432. case Shell::EscapeMode::Bareword:
  433. offset += 2; // X -> "\..."
  434. break;
  435. case Shell::EscapeMode::SingleQuotedString:
  436. offset += 4; // X -> '"\..."'
  437. break;
  438. case Shell::EscapeMode::DoubleQuotedString:
  439. // X -> \...
  440. break;
  441. }
  442. if (c > NumericLimits<u8>::max())
  443. offset += 8; // X -> "\uhhhhhhhh"
  444. else
  445. offset += 3; // X -> "\xhh"
  446. break;
  447. }
  448. ++offset;
  449. ++unescaped_offset;
  450. }
  451. return unescaped_offset;
  452. };
  453. Utf8View view { unescaped_text };
  454. if (view.validate())
  455. return do_find_offset(view);
  456. return do_find_offset(unescaped_text);
  457. }
  458. }
  459. namespace AK {
  460. template<>
  461. struct Traits<Shell::Shell::RunnablePath> : public GenericTraits<Shell::Shell::RunnablePath> {
  462. static constexpr bool is_trivial() { return false; }
  463. static bool equals(Shell::Shell::RunnablePath const& self, Shell::Shell::RunnablePath const& other)
  464. {
  465. return self == other;
  466. }
  467. static bool equals(Shell::Shell::RunnablePath const& self, StringView other)
  468. {
  469. return self.path == other;
  470. }
  471. static bool equals(Shell::Shell::RunnablePath const& self, DeprecatedString const& other)
  472. {
  473. return self.path == other;
  474. }
  475. };
  476. }