From: Jani Nikula <jani.nikula@intel.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 5/8] dim: avoid errors with rm $foo/ expanding to /
Date: Tue, 21 Mar 2017 13:15:59 +0200 [thread overview]
Message-ID: <874lymc234.fsf@intel.com> (raw)
In-Reply-To: <20170321104019.u43fynnuh467phvt@phenom.ffwll.local>
On Tue, 21 Mar 2017, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Tue, Mar 21, 2017 at 12:14:31PM +0200, Jani Nikula wrote:
>> Fix shellcheck SC2115: Use "${var:?}" to ensure this never expands to /.
>>
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> I'm not sold on these because if those are ever unset, dim will fail all
> over the place.
Yup, like at the top where we specifically ensure $DIM_PREFIX is not
empty!
> I'm leaning towards shutting this one up.
I know, I was divided about this one as well, but erred on the safe side
because 'rm -Rf /*' is such a huge failure mode.
I could lean either way.
BR,
Jani.
> -Daniel
>
>> ---
>> dim | 16 ++++++++++++----
>> 1 file changed, 12 insertions(+), 4 deletions(-)
>>
>> diff --git a/dim b/dim
>> index 0fe125335a67..8bbff67b3f80 100755
>> --- a/dim
>> +++ b/dim
>> @@ -461,18 +461,26 @@ function rr_cache_dir
>>
>> function update_rerere_cache
>> {
>> + local rerere
>> +
>> + rerere=$(rr_cache_dir)
>> +
>> cd $DIM_PREFIX/drm-rerere/
>> git pull
>> - mkdir $(rr_cache_dir) &> /dev/null || true
>> - cp rr-cache/* $(rr_cache_dir) -r
>> + mkdir ${rerere:?} &> /dev/null || true
>> + cp rr-cache/* ${rerere:?} -r
>> cd - > /dev/null
>> }
>>
>> function dim_revert_rerere
>> {
>> + local rerere
>> +
>> + rerere=$(rr_cache_dir)
>> +
>> cd $DIM_PREFIX/drm-rerere/
>> git revert $1
>> - rm $(rr_cache_dir)/* -Rf
>> + rm -Rf ${rerere:?}/*
>> }
>>
>> dim_alias_rebuild_nightly=rebuild-tip
>> @@ -974,7 +982,7 @@ function dim_remove_branch
>> cd $DIM_PREFIX/$DIM_DRM_INTEL
>>
>> if [[ -d $DIM_PREFIX/$branch ]] ; then
>> - rm -R $DIM_PREFIX/$branch
>> + rm -R ${DIM_PREFIX:?}/$branch
>> git worktree prune &> /dev/null || true
>> fi
>>
>> --
>> 2.1.4
>>
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-03-21 11:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 10:14 [PATCH 0/8] dim: shellcheck v0.4.4 fixes Jani Nikula
2017-03-21 10:14 ` [PATCH 1/8] dim: declare and assign separately Jani Nikula
2017-03-21 10:14 ` [PATCH 2/8] dim: use [ p ] || [ q ] instead of test -a/-o Jani Nikula
2017-03-21 10:14 ` [PATCH 3/8] dim: use read -r option Jani Nikula
2017-03-21 10:14 ` [PATCH 4/8] dim: silence shellcheck warning about sourced files Jani Nikula
2017-03-21 10:14 ` [PATCH 5/8] dim: avoid errors with rm $foo/ expanding to / Jani Nikula
2017-03-21 10:40 ` Daniel Vetter
2017-03-21 11:15 ` Jani Nikula [this message]
2017-03-21 12:50 ` Daniel Vetter
2017-03-22 10:41 ` David Weinehall
2017-03-22 10:53 ` Jani Nikula
2017-03-22 13:51 ` David Weinehall
2017-03-22 14:03 ` Jani Nikula
2017-03-21 10:14 ` [PATCH 6/8] dim: pipe dim_cite output directly instead of using echo Jani Nikula
2017-03-21 10:14 ` [PATCH 7/8] dim: use grep -c instead of grep|wc Jani Nikula
2017-03-21 10:41 ` Daniel Vetter
2017-03-21 11:12 ` [PATCH v2] dim: use grep -q " Jani Nikula
2017-03-21 10:14 ` [PATCH 8/8] dim: abstract -i interactive pause to a function Jani Nikula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874lymc234.fsf@intel.com \
--to=jani.nikula@intel.com \
--cc=daniel@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).