Commit graph

33 commits

Author SHA1 Message Date
Charles LeDoux
feb885fda6 Factor out parsing of options
Why:

* Want to be able to selectively apply filepath expansion to:
    1. Only options in a stowrc file.
    2. Only options that take a file path.

* Because of need 1, any expansion must be performed on stowrc options
  before merging with cli options.

* Because of need 2, stowrc options need to be parsed before expansion
  in order to know which options need expanding.

This change addresses the need by:

* Create parse_options()
    * Implements option parsing logic previously in process_options()
    * Takes an array as parameter instead of assuming ARGV
* Edit process_options() to still work as expected.
    * Only change was to call parse_options() instead of directly
      parsing ARGV

* By factoring out the option parsing code, we can reuse the existing
  parsing code for stowrc options.
    * Allows expansion of only the option itself, i.e expansion on
      "$HOME/target" rather than "--target=$HOME/target"
    * Allows easy determination of which options need expansion.
2019-06-25 19:38:25 +01:00
Adam Spiers
bb8b79e031 Don't warn when .stowrc is used
We fully support and expect some users using .stowrc, so there is
no reason to issue a warning when they do.
2019-06-25 19:38:25 +01:00
Adam Spiers
72ef83cebd Fix old descriptions of Stow (#22)
De-emphasise the package management aspects, since these days
almost everyone prefers to use modern package managers such as
rpm / dpkg / Nix for (system-wide) package management.

Also include more popular modern use cases for Stow such as management
of dotfiles and software compiled in the user's $HOME directory.

Fixes #22: https://github.com/aspiers/stow/issues/22
2019-06-25 16:52:33 +01:00
Adam Spiers
e79c5938bc Return non-zero exit code when invalid option is specified (#34)
Also add a unit test for this.

Fixes #34: https://github.com/aspiers/stow/issues/34
2019-06-25 15:43:08 +01:00
Adam Spiers
e618ef1526 remove duplicate "the" typo 2019-06-25 13:46:30 +01:00
Adam Spiers
1a752bf70b make chkstow honour $STOW_DIR environment variable
Thanks to Matan Nassau for reporting this deficiency.
2019-02-09 17:03:45 +00:00
Adam Spiers
8d738353f8 fix documentation for --verbose
It actually goes up to 5 these days.  Thanks to Kristoffer Haugsbakk
for spotting that:

  http://lists.gnu.org/archive/html/bug-stow/2016-08/msg00000.html
2016-12-18 23:11:23 +00:00
Joris Vankerschaver
182acbbb64 Special processing for dotfiles 2016-10-04 17:51:01 +01:00
LE Manh Cuong
8544b2f0f5 Allow directory with trailing and leading spaces
- The `sanitize_path_options` functions remove all trailing
 and leading spaces. So any valid directory like ` 123`,
 `123 ` can not be used

 - Also if there are two directories ` 123` and `123`, and if
 user pick the ` 123` as option to `-d` or `-t`, then stow pick
 directory `123` as the argument instead of ` 123` as user want.

    ```
    STOW_DIR=. stow -n -v3 -t \ 123 456
    stow dir is /tmp/test
    stow dir path relative to target 123 is ..
    cwd now 123
    cwd restored to /tmp/test
    cwd now 123
    Planning stow of package 456...
    Stowing contents of ../456 (cwd=/tmp/test/123)
    Planning stow of package 456... done
    cwd restored to /tmp/test
    WARNING: in simulation mode so not modifying filesystem.
    ```
 - This commit remove the check in `sanitize_path_options` function,
 and now stow can work with those directories. There have been a check
 for valid directory, so we are safe.
2015-11-13 20:17:58 +07:00
Adam Spiers
a111eeb8ae Do more validation on --dir / --target directories (#7)
Previously STOW_DIR=0 would cause the cwd to be used as the STOW_DIR.
Make that instead raise an error.  Do similar validation on the target
directory.

Closes #7 - https://github.com/aspiers/stow/pull/7
2015-11-11 12:30:50 +00:00
Adam Spiers
d0f3e5458f Correctly handle empty STOW_DIR (#5, #6)
In shell, a variable is often considered unset even if it is
set to the empty string.  In other words,

  STOW_DIR= stow [args]

is an idiomatic alternative to writing:

  unset STOW_DIR
  stow [args]

and it also has the advantage of temporarily "unsetting" STOW_DIR
for a single command.

Therefore we should treat STOW_DIR being set to the empty string
as equivalent to it not being set at all.

Thanks to Cuong Manh Le for highlighting this issue!

Fixes #6  - https://github.com/aspiers/stow/issues/6
Closes #5 - https://github.com/aspiers/stow/pull/5
2015-11-11 11:28:47 +00:00
Adam Spiers
67936bd7de Fix RT ticket #75349
https://rt.cpan.org/Ticket/Display.html?id=75349
2012-07-09 01:05:27 +01:00
Adam Spiers
db7819dbf2 Bug #36478 - fix Perl warnings from 'require 5.6.1;'
https://savannah.gnu.org/bugs/?36478
2012-05-16 11:02:40 +01:00
Adam Spiers
ed12c787df Add --no-folding option. 2012-02-18 20:33:34 +00:00
Adam Spiers
17d3586e84 Remove -a option for safety reasons (but keep --adopt). 2012-02-18 20:33:34 +00:00
Adam Spiers
2c5950ed00 Add --adopt to usage text. 2012-02-18 17:14:50 +00:00
Adam Spiers
7b36267dd2 Improve ordering of options in usage text. 2012-02-18 17:14:50 +00:00
Adam Spiers
9c6faebb95 Include --simulate in usage text. 2012-02-18 11:53:46 +00:00
Adam Spiers
25b9ce0f21 Remove reference to old FSF address (thank you rpmlint for catching this!) 2012-01-12 17:54:32 +00:00
Adam Spiers
7e44666640 Add --adopt / -a option. 2012-01-09 21:29:34 +00:00
Adam Spiers
d3847e951a Make stow script return true for t/stow.t
According to http://matrix.cpantesters.org/?dist=Stow
this only seems to be an issue with Perl <= 5.8.7.
2011-12-11 13:23:37 +00:00
Adam Spiers
195c80e9d7 Significantly improve the handling of --with-pmdir. 2011-12-07 20:48:50 +00:00
Adam Spiers
8817815059 Make capitalisation consistent in usage text. 2011-12-07 20:31:20 +00:00
Adam Spiers
bc661ae77b Add bug-reporting email address and a couple of URLs to usage text
to comply with GNU Coding Standards for --help option.
2011-12-06 16:26:29 +00:00
Adam Spiers
4d6c23600b Fix corner case where only -d is specified as a single directory. 2011-12-01 16:23:04 +00:00
Adam Spiers
1f41616b12 Tidy up chkstow code and documentation. 2011-11-26 16:34:57 +00:00
Adam Spiers
bcac91d68a Remove quote stripping code.
I'm guessing it was added due to a misunderstanding of how shell
quoting works.  When you invoke

   stow --ignore=".#.*" ...

the shell strips out the quotes before the Perl process ever sees them.
I can't imagine any sensible scenario in which you would need to invoke

   stow --ignore='"foo"'

but if the user has a filename containing quotes at the beginning and
end, they can now choose to ignore it (prior to this patch, they couldn't).
2011-11-26 16:34:57 +00:00
Adam Spiers
3d414dc071 Improve conflict reporting 2011-11-26 16:34:57 +00:00
Adam Spiers
55d3f05cf2 Ditch obsolete --conflicts option and update misleading documentation. 2011-11-26 16:34:57 +00:00
Adam Spiers
0db112441f Strip superfluous quotes from $hash{'lookups'} 2011-11-26 16:34:54 +00:00
Adam Spiers
a7262a98bc Avoid use of map in void context 2011-11-26 15:10:28 +00:00
Adam Spiers
a84ba4c16d Convert man page to POD format which is easier to maintain within stow.in. 2011-11-26 15:10:27 +00:00
Adam Spiers
58625800ee Reorganise more files into subdirectories and add CPAN support via Module::Build 2011-11-26 15:10:26 +00:00