43 Commits

Author SHA1 Message Date
Heath Stewart
42caf20fa4
Add PowerShell (pwsh) completion support
Resolves #19403
2025-03-02 18:17:38 -08:00
Issy Long
34b4cc796f
Early return if Shell#profile's preferred is nil 2025-01-22 22:01:34 +00:00
Issy Long
975a707b3c
Bump some utils/ files to Sorbet typed: strict 2025-01-22 22:01:34 +00:00
Bo Anderson
6db4ed2793
Replace some include Kernel usages with requires_ancestor 2024-08-20 19:10:14 +01:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Leo Heitmann Ruiz
4ac57d85b2 Read ZDOTDIR environment variable 2024-06-12 16:53:43 +02:00
Carlo Cabrera
6b59c032a7
utils/shell: add + to safe shell characters
`+` does not require escaping in the shell. (Not for Bash and Zsh, at
least.)
2024-05-18 16:01:07 +08:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Issy Long
f682147598
Fix RuboCop Style/RedundantFreeze offenses 2024-01-18 22:20:01 +00:00
Bo Anderson
5692c8ecbf
Fix style violations under newer RuboCop 2023-12-14 05:47:12 +00:00
Cthulhux
1c4c3194e6
got rid of rc_quote
The only "special" case about `rc` quoting is that strings that contain apostrophes need to contain double apostrophes instead. It seems unlikely that this will happen in Homebrew.
2023-11-29 21:40:51 +01:00
Cthulhux
d26a408870
Support the rc shell. Fixes #16264
(In my tests, changes to `shellenv.sh` weren't required, so I didn't bother.)
2023-11-29 02:22:49 +01:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Mike McQuaid
32463227ac
Deprecate preferred_shell and shell_profile.
I know that we're outside our normal deprecation cycle but: these are
totally broken with the API and it doesn't make sense to support them
only for non-core formulae.
2023-02-28 15:02:06 +00:00
Bo Anderson
e78665f4f7
Replace ENV["HOME"] with Dir.home 2022-06-17 19:47:57 +01:00
Niklas Higi
00f209e16e
Recommend interactive usage of fish_add_path
Since the `fish_add_path` command modifies a universal Fish variable
(which is automatically persisted to a file) it's unnecessary to run it
again every time a new shell is opened.
2022-02-05 16:29:09 +01:00
David Xia
7920006020
fix: use recommended way of updating Fish shell $PATH
fixes https://github.com/Homebrew/brew/issues/8965

See Fish docs https://fishshell.com/docs/current/tutorial.html#path.

> A faster way is to use the `fish_add_path function`... The advantage is that
> you don't have to go mucking around in files: just run this once at the
> command line, and it will affect the current session and all future instances
> too.
>
> Or you can modify `$fish_user_paths` yourself, but you should be careful not
> to append to it unconditionally in config.fish, or it will grow longer and
> longer.
2021-05-08 21:19:19 -07:00
Markus Reiter
61b79318ed Move include Kernel into .rbi files again and split up existing .rbi files. 2020-10-10 19:10:58 +02:00
Markus Reiter
8fabc56a22 Inline type annotations for Utils::Shell. 2020-10-10 15:31:32 +02:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Mike McQuaid
3a91c37e66
Fix RuboCop checks. 2020-08-19 17:12:32 +01:00
Shaun Jackman
133ee7966d shell: Use .profile unless .bash_profile exists 2020-05-13 09:30:02 -07:00
Mike McQuaid
36bc11b01a
utils/shell: match preferred shell by symbol. 2019-10-08 12:10:31 +01:00
David O'Trakoun
5ca4b43383
Update Library/Homebrew/utils/shell.rb
Co-Authored-By: Mike McQuaid <mike@mikemcquaid.com>
2019-10-07 10:25:41 -04:00
David O'Trakoun
960b8b659c
Support for zsh ZDOTDIR, FIX #6533
- Add test spec with ZDOTDIR set and unset
2019-10-06 12:40:18 -04:00
Frantisek Holop
6e691320f8 teach brew about mksh 2019-05-12 20:45:09 +02:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
737b84b54b
brew style --fix fixes. 2018-11-02 17:29:23 +00:00
EricFromCanada
20167e5f1b Adjust comments to tidy API docs output. 2018-10-18 21:42:43 -04:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Mike McQuaid
74c77db5bd shell: tweak export_value parameters.
Let’s have a default value for shell (considering this isn’t a public
API) to make it easier to use.
2018-07-26 10:48:25 +01:00
Maxim Belkin
7b99ac58ab
Remove ~ from UNSAFE_SHELL_CHAR 2018-05-14 04:45:59 -05:00
Maxim Belkin
e5435dfeb7
Cross-platform diagnostics. 2018-05-14 04:44:15 -05:00
Mike McQuaid
cf5fdeef1d Rubocop: manual rule fixes. 2017-09-24 21:23:59 +01:00
Mike McQuaid
ba3c46d24f More deprecations.
Deprecate more methods. Internal APIs have been verified to be unused
elsewhere and removed. External APIs have had deprecation methods added.
Existing deprecations have been either upgraded to produce warnings or
no longer deprecated and the reasoning documented.
2017-04-22 16:28:07 +01:00
Mike McQuaid
3982950e61 rubocop --auto-correct all hash-rocket usage. 2016-09-17 16:14:13 +01:00
Mike McQuaid
94f763e9c7 utils/shell: 2016-09-11 19:13:01 +01:00
Mike McQuaid
aa3d53f249 utils/shell: fix Rubocop warnings. 2016-09-11 19:13:00 +01:00
Misty De Meo
e40d70c761 Utils::Shell: convert to use module_function 2016-09-05 14:45:29 +10:00
Greg Nisbet
dcc3377aa3 move shell_profile to compat/utils.rb & deprecate 2016-08-10 23:21:30 -07:00
Greg Nisbet
bf63c08d50 tests for shell-specific diagnostic message 2016-08-10 23:21:30 -07:00
Greg Nisbet
f0cc815d86 Multi-shell diagnostic check 2016-08-10 23:21:30 -07:00
Greg Nisbet
9a29a306cf resolve conflict in diagnostic.rb 2016-08-10 23:19:09 -07:00