All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/bash_aliases, scripts/modified_pages.sh: Move scripts/modified_pages.sh to a function man_gitstaged()
@ 2021-02-22 14:03 Alejandro Colomar
  2021-02-22 14:58 ` Jakub Wilk
  0 siblings, 1 reply; 5+ messages in thread
From: Alejandro Colomar @ 2021-02-22 14:03 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man

This allows calling the function from anywhere in the git tree,
without having to calculate the relative route to the script.
It also makes more sense for this piece of code to be a function
than a script.

Minor changes: replace <"> by <'>.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 scripts/bash_aliases      | 17 ++++++++++++++++-
 scripts/modified_pages.sh | 34 ----------------------------------
 2 files changed, 16 insertions(+), 35 deletions(-)
 delete mode 100755 scripts/modified_pages.sh

diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index c0c8bc33e..127ed5d08 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 ########################################################################
 #
-# (C) Copyright 2021, Alejandro Colomar
+# (C) Copyright 2020, 2021, Alejandro Colomar
 # These functions are free software; you can redistribute them and/or
 # modify them under the terms of the GNU General Public License
 # as published by the Free Software Foundation; version 2.
@@ -147,6 +147,21 @@ function pdfman()
 	xdg-open ${tmp};
 }
 
+#  man_gitstaged  prints a list of all files with changes staged for commit
+# (basename only if the files are within <man?/>), separated by ", ".
+# Usage example:  .../man-pages$ git commit -m "$(man_gitstaged): msg";
+
+function man_gitstaged()
+{
+	git status							\
+	|sed '/Changes not staged for commit:/q'			\
+	|grep -E '^\s*(modified|deleted|new file):'			\
+	|sed 's/^.*:\s*/, /'						\
+	|sed 's%man[1-9]/%%'						\
+	|tr -d '\n'							\
+	|sed 's/^, //'
+}
+
 ########################################################################
 #	Glibc
 
diff --git a/scripts/modified_pages.sh b/scripts/modified_pages.sh
deleted file mode 100755
index f6c4a6cea..000000000
--- a/scripts/modified_pages.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-
-## SPDX-License-Identifier: GPL-2.0-only
-########################################################################
-##
-## (C) Copyright 2020, Alejandro Colomar
-## This program is free software; you can redistribute it and/or
-## modify it under the terms of the GNU General Public License
-## as published by the Free Software Foundation; version 2.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details
-## (http://www.gnu.org/licenses/gpl-2.0.html).
-##
-########################################################################
-##
-## The output of this script is a
-## list of all files with changes staged for commit
-## (basename only if the files are within "man?/"),
-## separated by ", ".
-## Usage:
-## git commit -m "$(./scripts/modified_pages.sh): Short message here"
-##
-
-
-git status							\
-|sed "/Changes not staged for commit:/q"			\
-|grep -E "^\s*(modified|deleted|new file):"			\
-|sed "s/^.*:\s*/, /"						\
-|sed "s%man[1-9]/%%"						\
-|tr -d '\n'							\
-|sed "s/^, //"
-- 
2.30.1.721.g45526154a5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts/bash_aliases, scripts/modified_pages.sh: Move scripts/modified_pages.sh to a function man_gitstaged()
  2021-02-22 14:03 [PATCH] scripts/bash_aliases, scripts/modified_pages.sh: Move scripts/modified_pages.sh to a function man_gitstaged() Alejandro Colomar
@ 2021-02-22 14:58 ` Jakub Wilk
  2021-02-22 15:34   ` Alejandro Colomar (man-pages)
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Wilk @ 2021-02-22 14:58 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Michael Kerrisk, linux-man

* Alejandro Colomar <alx.manpages@gmail.com>, 2021-02-22, 15:03:
>+	git status							\
>+	|sed '/Changes not staged for commit:/q'			\
>+	|grep -E '^\s*(modified|deleted|new file):'			\

"git status" (without further options) is not suitable for scripting: 
"The default, long format, is designed to be human readable, verbose and 
descriptive. Its contents and format are subject to change at any time."

You could use "git status --porcelain" instead, which has stable and 
(supposedly) easy to parse format. Or, better, you could use "git diff 
--staged --name-only".

-- 
Jakub Wilk

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts/bash_aliases, scripts/modified_pages.sh: Move scripts/modified_pages.sh to a function man_gitstaged()
  2021-02-22 14:58 ` Jakub Wilk
@ 2021-02-22 15:34   ` Alejandro Colomar (man-pages)
  0 siblings, 0 replies; 5+ messages in thread
From: Alejandro Colomar (man-pages) @ 2021-02-22 15:34 UTC (permalink / raw)
  To: Jakub Wilk; +Cc: Michael Kerrisk, linux-man

Hey Jakub,

On 2/22/21 3:58 PM, Jakub Wilk wrote:
> * Alejandro Colomar <alx.manpages@gmail.com>, 2021-02-22, 15:03:
>> +    git status                            \
>> +    |sed '/Changes not staged for commit:/q'            \
>> +    |grep -E '^\s*(modified|deleted|new file):'            \
> 
> "git status" (without further options) is not suitable for scripting: 
> "The default, long format, is designed to be human readable, verbose and 
> descriptive. Its contents and format are subject to change at any time." >
> You could use "git status --porcelain" instead, which has stable and 
> (supposedly) easy to parse format. Or, better, you could use "git diff 
> --staged --name-only".
> 

I know I shouldn't script around 'git status'; actually I found out that 
yesterday.  When I read that, I tried to script around 'git status 
--porcelain', but it's more complex (at least to me, at first glance), 
and I gave up.

However, 'git diff --staged --name-only' is exactly what I need!  I'll 
prepare a patch with that in a few minutes.

Michael, so that git can follow the code movement relatively easily, 
I'll write that patch on top of this one, so you can already apply this one.

Thanks a lot!!

Alex

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts/bash_aliases, scripts/modified_pages.sh: Move scripts/modified_pages.sh to a function man_gitstaged()
  2021-05-09 21:38 ` [PATCH] scripts/bash_aliases, scripts/modified_pages.sh: Move scripts/modified_pages.sh to a function man_gitstaged() Alejandro Colomar
@ 2021-05-09 23:27   ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Kerrisk (man-pages) @ 2021-05-09 23:27 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: mtk.manpages, linux-man

Hi Alex,

On 5/10/21 9:38 AM, Alejandro Colomar wrote:
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>

Applied. (I take these patches to your own scripts on trust...)

Thanks,

Michael


> ---
>  scripts/bash_aliases      | 17 ++++++++++++++++-
>  scripts/modified_pages.sh | 34 ----------------------------------
>  2 files changed, 16 insertions(+), 35 deletions(-)
>  delete mode 100755 scripts/modified_pages.sh
> 
> diff --git a/scripts/bash_aliases b/scripts/bash_aliases
> index a14c65cd4..8cedc4efc 100644
> --- a/scripts/bash_aliases
> +++ b/scripts/bash_aliases
> @@ -1,7 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  ########################################################################
>  #
> -# (C) Copyright 2021, Alejandro Colomar
> +# (C) Copyright 2020, 2021, Alejandro Colomar
>  # These functions are free software; you can redistribute them and/or
>  # modify them under the terms of the GNU General Public License
>  # as published by the Free Software Foundation; version 2.
> @@ -147,6 +147,21 @@ function pdfman()
>  	xdg-open ${tmp};
>  }
>  
> +#  man_gitstaged  prints a list of all files with changes staged for commit
> +# (basename only if the files are within <man?/>), separated by ", ".
> +# Usage example:  .../man-pages$ git commit -m "$(man_gitstaged): msg";
> +
> +function man_gitstaged()
> +{
> +	git status							\
> +	|sed "/Changes not staged for commit:/q"			\
> +	|grep -E "^\s*(modified|deleted|new file):"			\
> +	|sed "s/^.*:\s*/, /"						\
> +	|sed "s%man[1-9]/%%"						\
> +	|tr -d '\n'							\
> +	|sed "s/^, //"
> +}
> +
>  ########################################################################
>  #	Glibc
>  
> diff --git a/scripts/modified_pages.sh b/scripts/modified_pages.sh
> deleted file mode 100755
> index f6c4a6cea..000000000
> --- a/scripts/modified_pages.sh
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -#!/bin/bash
> -
> -## SPDX-License-Identifier: GPL-2.0-only
> -########################################################################
> -##
> -## (C) Copyright 2020, Alejandro Colomar
> -## This program is free software; you can redistribute it and/or
> -## modify it under the terms of the GNU General Public License
> -## as published by the Free Software Foundation; version 2.
> -##
> -## This program is distributed in the hope that it will be useful,
> -## but WITHOUT ANY WARRANTY; without even the implied warranty of
> -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> -## GNU General Public License for more details
> -## (http://www.gnu.org/licenses/gpl-2.0.html).
> -##
> -########################################################################
> -##
> -## The output of this script is a
> -## list of all files with changes staged for commit
> -## (basename only if the files are within "man?/"),
> -## separated by ", ".
> -## Usage:
> -## git commit -m "$(./scripts/modified_pages.sh): Short message here"
> -##
> -
> -
> -git status							\
> -|sed "/Changes not staged for commit:/q"			\
> -|grep -E "^\s*(modified|deleted|new file):"			\
> -|sed "s/^.*:\s*/, /"						\
> -|sed "s%man[1-9]/%%"						\
> -|tr -d '\n'							\
> -|sed "s/^, //"
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] scripts/bash_aliases, scripts/modified_pages.sh: Move scripts/modified_pages.sh to a function man_gitstaged()
  2021-05-09 21:38 [PATCH] fflush.3: SEE ALSO: Add fpurge(3) Alejandro Colomar
@ 2021-05-09 21:38 ` Alejandro Colomar
  2021-05-09 23:27   ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 5+ messages in thread
From: Alejandro Colomar @ 2021-05-09 21:38 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
 scripts/bash_aliases      | 17 ++++++++++++++++-
 scripts/modified_pages.sh | 34 ----------------------------------
 2 files changed, 16 insertions(+), 35 deletions(-)
 delete mode 100755 scripts/modified_pages.sh

diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index a14c65cd4..8cedc4efc 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 ########################################################################
 #
-# (C) Copyright 2021, Alejandro Colomar
+# (C) Copyright 2020, 2021, Alejandro Colomar
 # These functions are free software; you can redistribute them and/or
 # modify them under the terms of the GNU General Public License
 # as published by the Free Software Foundation; version 2.
@@ -147,6 +147,21 @@ function pdfman()
 	xdg-open ${tmp};
 }
 
+#  man_gitstaged  prints a list of all files with changes staged for commit
+# (basename only if the files are within <man?/>), separated by ", ".
+# Usage example:  .../man-pages$ git commit -m "$(man_gitstaged): msg";
+
+function man_gitstaged()
+{
+	git status							\
+	|sed "/Changes not staged for commit:/q"			\
+	|grep -E "^\s*(modified|deleted|new file):"			\
+	|sed "s/^.*:\s*/, /"						\
+	|sed "s%man[1-9]/%%"						\
+	|tr -d '\n'							\
+	|sed "s/^, //"
+}
+
 ########################################################################
 #	Glibc
 
diff --git a/scripts/modified_pages.sh b/scripts/modified_pages.sh
deleted file mode 100755
index f6c4a6cea..000000000
--- a/scripts/modified_pages.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-
-## SPDX-License-Identifier: GPL-2.0-only
-########################################################################
-##
-## (C) Copyright 2020, Alejandro Colomar
-## This program is free software; you can redistribute it and/or
-## modify it under the terms of the GNU General Public License
-## as published by the Free Software Foundation; version 2.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details
-## (http://www.gnu.org/licenses/gpl-2.0.html).
-##
-########################################################################
-##
-## The output of this script is a
-## list of all files with changes staged for commit
-## (basename only if the files are within "man?/"),
-## separated by ", ".
-## Usage:
-## git commit -m "$(./scripts/modified_pages.sh): Short message here"
-##
-
-
-git status							\
-|sed "/Changes not staged for commit:/q"			\
-|grep -E "^\s*(modified|deleted|new file):"			\
-|sed "s/^.*:\s*/, /"						\
-|sed "s%man[1-9]/%%"						\
-|tr -d '\n'							\
-|sed "s/^, //"
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-09 23:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22 14:03 [PATCH] scripts/bash_aliases, scripts/modified_pages.sh: Move scripts/modified_pages.sh to a function man_gitstaged() Alejandro Colomar
2021-02-22 14:58 ` Jakub Wilk
2021-02-22 15:34   ` Alejandro Colomar (man-pages)
2021-05-09 21:38 [PATCH] fflush.3: SEE ALSO: Add fpurge(3) Alejandro Colomar
2021-05-09 21:38 ` [PATCH] scripts/bash_aliases, scripts/modified_pages.sh: Move scripts/modified_pages.sh to a function man_gitstaged() Alejandro Colomar
2021-05-09 23:27   ` Michael Kerrisk (man-pages)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.